gpt4 book ai didi

android - WebView.setWebContentsDebuggingEnabled(false) 但我可以在安装已签名的 APK 后调试代码

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:44:50 30 4
gpt4 key购买 nike

我正在尝试发布我用 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);
}
}
}
}

在 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
}

但它仍然无法正常工作...我仍然能够调试 html js 文件

最佳答案

您的代码中存在错误。它无条件地在 KitKat 和更新版本上的所有应用程序的 WebView 中启用调试,无论该应用程序是否被标记为可调试。

0 != (getApplicationInfo().flags = ApplicationInfo.FLAG_DEBUGGABLE) 实际上应该是 0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)

关于android - WebView.setWebContentsDebuggingEnabled(false) 但我可以在安装已签名的 APK 后调试代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25556409/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com