我正在尝试使用Webview,并使用第三方SDK。当我尝试访问Info info = AdvertisingIdClient.getAdvertisingIdInfo(MainActivity.this);
时,它会给我错误。以下是我的代码:
public class MainActivity extends Activity {
public MobileAppTracker mobileAppTracker = null;
WebView webview;
ProgressBar progressbar;
String url = "http://www.trade-24.com/forex-secrets-lp?lName=1348&tag1=mobileapp&Ads_Server=102c178defae24bd76883edbf22069&Campaign_Id=2&Link_ID=688&UtmCreative=";
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize MAT
MobileAppTracker.init(getApplicationContext(), "", "");
mobileAppTracker = MobileAppTracker.getInstance();
new Thread(new Runnable() {
@Override
public void run() {
try {
Info info = AdvertisingIdClient.getAdvertisingIdInfo(MainActivity.this);
mobileAppTracker.setGoogleAdvertisingId(info.getId(), info.isLimitAdTrackingEnabled());
} catch (IOException e) {
mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID));
} catch (GooglePlayServicesNotAvailableException e) {
mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID));
} catch (GooglePlayServicesRepairableException e) {
mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID));
} catch (NullPointerException e) {
mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID));
}
}
}).start();
webview = (WebView) findViewById(R.id.webview);
progressbar = (ProgressBar) findViewById(R.id.progress);
webview.loadUrl(url);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
MainActivity.this.setProgress(progress * 100);
if (progress < 100 && progressbar.getVisibility() == ProgressBar.GONE) {
progressbar.setVisibility(View.VISIBLE);
}
progressbar.setProgress(progress);
if (progress == 100 && progressbar.getVisibility() == ProgressBar.VISIBLE) {
progressbar.setVisibility(ProgressBar.GONE);
}
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(MainActivity.this, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
@Override
public void onPageFinished(WebView view, String url) {
progressbar.setVisibility(ProgressBar.GONE);
super.onPageFinished(view, url);
}
});
}
@Override
protected void onResume() {
super.onResume();
mobileAppTracker.setReferralSources(this);
// MAT will not function unless the measureSession call is included
mobileAppTracker.measureSession();
}
}
我在stackoverflow中搜索过,没有答案解决了我的问题。我已经在libs文件夹中添加了库,并且还添加到构建路径并且检查了它。
logcat的 的修改
我正在获得新的Logcat像这样:我使用了谷歌播放服务(修订版20),并尝试了谷歌播放服务以进行适合预览。
10-28 04:07:48.494: I/dalvikvm(1714): Could not find method com.google.android.gms.ads.identifier.AdvertisingIdClient.getAdvertisingIdInfo, referenced from method com.fxguru.MainActivity$1.run
10-28 04:07:48.494: W/dalvikvm(1714): VFY: unable to resolve static method 137: Lcom/google/android/gms/ads/identifier/AdvertisingIdClient;.getAdvertisingIdInfo (Landroid/content/Context;)Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$Info;
10-28 04:07:48.504: D/dalvikvm(1714): VFY: replacing opcode 0x71 at 0x0006
10-28 04:07:48.504: W/dalvikvm(1714): VFY: unable to resolve exception class 91 (Lcom/google/android/gms/common/GooglePlayServicesNotAvailableException;)
10-28 04:07:48.514: W/dalvikvm(1714): VFY: unable to find exception handler at addr 0x2f
10-28 04:07:48.514: W/dalvikvm(1714): VFY: rejected Lcom/fxguru/MainActivity$1;.run ()V
10-28 04:07:48.514: W/dalvikvm(1714): VFY: rejecting opcode 0x0d at 0x002f
10-28 04:07:48.514: W/dalvikvm(1714): VFY: rejected Lcom/fxguru/MainActivity$1;.run ()V
10-28 04:07:48.514: W/dalvikvm(1714): Verifier rejected class Lcom/fxguru/MainActivity$1;
10-28 04:07:48.514: D/AndroidRuntime(1714): Shutting down VM
10-28 04:07:48.514: W/dalvikvm(1714): threadid=1: thread exiting with uncaught exception (group=0xb3aedba8)
10-28 04:07:48.564: E/AndroidRuntime(1714): FATAL EXCEPTION: main
10-28 04:07:48.564: E/AndroidRuntime(1714): Process: com.fxguru, PID: 1714
10-28 04:07:48.564: E/AndroidRuntime(1714): java.lang.VerifyError: com/fxguru/MainActivity$1
10-28 04:07:48.564: E/AndroidRuntime(1714): at com.fxguru.MainActivity.onCreate(MainActivity.java:48)
10-28 04:07:48.564: E/AndroidRuntime(1714): at android.app.Activity.performCreate(Activity.java:5231)
10-28 04:07:48.564: E/AndroidRuntime(1714): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-28 04:07:48.564: E/AndroidRuntime(1714): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
10-28 04:07:48.564: E/AndroidRuntime(1714): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
10-28 04:07:48.564: E/AndroidRuntime(1714): at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-28 04:07:48.564: E/AndroidRuntime(1714): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-28 04:07:48.564: E/AndroidRuntime(1714): at android.os.Handler.dispatchMessage(Handler.java:102)
10-28 04:07:48.564: E/AndroidRuntime(1714): at android.os.Looper.loop(Looper.java:136)
10-28 04:07:48.564: E/AndroidRuntime(1714): at android.app.ActivityThread.main(ActivityThread.java:5017)
10-28 04:07:48.564: E/AndroidRuntime(1714): at java.lang.reflect.Method.invokeNative(Native Method)
10-28 04:07:48.564: E/AndroidRuntime(1714): at java.lang.reflect.Method.invoke(Method.java:515)
10-28 04:07:48.564: E/AndroidRuntime(1714): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-28 04:07:48.564: E/AndroidRuntime(1714): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-28 04:07:48.564: E/AndroidRuntime(1714): at dalvik.system.NativeStart.main(Native Method)
10-28 04:07:54.624: I/Process(1714): Sending signal. PID: 1714 SIG: 9
答案 0 :(得分:3)
可能重复 Android java.lang.VerifyError?
VerifyError消息上方是否有任何输出,如此答案提及的那样? https://stackoverflow.com/a/3549131