Luc*_*kyy 6 android apk cordova
我试图发布我用cordova创建的Android应用程序,并在发布时我遵循所有步骤,如android:debuggable ="false"甚至删除此行作为其最新建议但问题是我在我的模拟器中安装签名的构建版本我可以调试它......任何帮助?
更新: -
根据建议,我试过..
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);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
in public void onCreate(Bundle 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
}
Run Code Online (Sandbox Code Playgroud)
但它仍然无法工作......我仍然能够调试html js文件
您的代码中有一个错误。它无条件地在KitKat和更高版本上的所有应用程序WebView中启用调试,无论该应用程序是否标记为可调试。
0 != (getApplicationInfo().flags = ApplicationInfo.FLAG_DEBUGGABLE)应该是0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)。
你必须将你的 webview 设置为 not debuggable:
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;
}
});
}
Run Code Online (Sandbox Code Playgroud)
和
@SuppressLint("NewApi")
public class OnlyForKitKat {
public static void enableWebViewDebugging() {
WebView.setWebContentsDebuggingEnabled(false);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11677 次 |
| 最近记录: |