2014-08-28 247 views
5

我試圖發佈我的android應用程序創建與科爾多瓦,併發布時,我遵循所有步驟像android:debuggable =「false」甚至刪除這條線作爲其最新的建議,但問題是當我在我的模擬器中安裝簽名的版本版本我能夠調試它...任何幫助?WebView.setWebContentsDebuggingEnabled(false),但我可以在安裝已簽名APK後調試代碼

更新: -

按照建議我試圖..

public class appname extends CordovaActivity 
{ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     super.init(); 
     super.loadUrl(Config.getStartUrl()); 
     if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ 
      if(0 != (getApplicationInfo().flags = ApplicationInfo.FLAG_DEBUGGABLE)){ 
       //Log.i("Your app", "Disable web debugging"); 
       WebView.setWebContentsDebuggingEnabled(false); 
      } 
     } 
    } 
} 

在公共無效的onCreate(捆綁savedInstanceState){}

實測值這段代碼在CordovaWebView.java

if((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 && 
       android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) 
      { 
       setWebContentsDebuggingEnabled(true); // I tried setting this false as well 
      } 

但它仍然沒有工作......我仍然能夠調試html js fil es

+0

你如何調試旅遊代碼? – 2014-08-29 04:36:21

+0

通過鍍鉻設備工具 – Luckyy 2014-08-29 05:51:31

回答

0

你必須設置你的webview不可調試: WebView.setWebContentsDebuggingEnabled(false)。我已經檢查:

public class HTML5Application extends CordovaActivity 
{ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     //webView.setWebChromeClient(new WebChromeClient()); 
     super.onCreate(savedInstanceState); 
     super.init(); 
     // Set by <content src="index.html" /> in config.xml 
     super.loadUrl(Config.getStartUrl()); 
     //super.loadUrl("file:///android_asset/www/index.html") 

     if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ 
      Log.i("xxxxxx", "Enabling web debugging"); 
      OnlyForKitKat.enableWebViewDebugging(); 
     } 

     appView.setOnKeyListener(new OnKeyListener() { 
      @Override 
      public boolean onKey(View v, int keyCode, KeyEvent event) { 
       if (keyCode == KeyEvent.KEYCODE_BACK) return true; 
       return false; 
      } 
     }); 
    } 

@SuppressLint("NewApi") 
public class OnlyForKitKat { 

    public static void enableWebViewDebugging() { 
     WebView.setWebContentsDebuggingEnabled(false); 
    } 

} 

enter image description here

+1

試過如上....我粘貼了整個代碼,它不工作 – Luckyy 2014-08-29 15:58:11

+0

chrome :: // inspect不顯示調試頁面。如果(0!=(getApplicationInfo()。flags = ApplicationInfo.FLAG_DEBUGGABLE)){? – 2014-08-29 17:34:26

+0

THANKs很多...但只是禁用條件並沒有解決調試問題 – Luckyy 2014-08-29 18:13:20

1

有在你的代碼中的錯誤。它無條件地啓用在KitKat和更新的所有應用程序的WebView中進行調試,而不管應用程序是否標記爲可調試。

0 != (getApplicationInfo().flags = ApplicationInfo.FLAG_DEBUGGABLE)實際上應該是0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)

相關問題