Getting java.lang.VerifyError at AdvertisingIdClient .

200 views
Skip to first unread message

Dhaval Gondaliya

unread,
Oct 28, 2014, 3:43:52 AM10/28/14
to android-...@googlegroups.com
Hello,
I added google play service in my project as a library. I am trying to get device id using AdvertisingIdClient. but it causes error.

Could not find method com.google.android.gms.ads.identifier.AdvertisingIdClient.getAdvertisingIdInfo, referenced from method com.fxguru.MainActivity$1.run

Here is my code:

public class MainActivity extends Activity {

MobileAppTracker mobileAppTracker;
WebView webview;
ProgressDialog progressDialog;
SharedPreferences preferences;
Editor editor;

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Initialize MAT
MobileAppTracker.init(getApplicationContext(), "160206", "408f8e69aed2817e86172aca5fc5c085");
mobileAppTracker = MobileAppTracker.getInstance();

new Thread(new Runnable() {
@Override
public void run() {
// See sample code at
try {
Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());
mobileAppTracker.setGoogleAdvertisingId(adInfo.getId(), adInfo.isLimitAdTrackingEnabled());
} catch (IOException e) {
// Unrecoverable error connecting to Google Play services
// (e.g.,
// the old version of the service doesn't support getting
// AdvertisingId).
mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID));
} catch (GooglePlayServicesNotAvailableException e) {
// Google Play services is not available entirely.
mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID));
} catch (GooglePlayServicesRepairableException e) {
// Encountered a recoverable error connecting to Google Play
// services.
mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID));
} catch (NullPointerException e) {
// getId() is sometimes null
mobileAppTracker.setAndroidId(Secure.getString(getContentResolver(), Secure.ANDROID_ID));
}
}
}).start();

preferences = getApplicationContext().getSharedPreferences("Logging", Context.MODE_PRIVATE);

editor = preferences.edit();

webview = (WebView) findViewById(R.id.webview);

webview.loadUrl(url);
progressDialog = ProgressDialog.show(MainActivity.this, "", "Loading...");

webview.getSettings().setJavaScriptEnabled(true);

webview.setWebViewClient(new WebViewClient() {

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
progressDialog.show();
super.onPageStarted(view, url, favicon);
}

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) {

progressDialog.dismiss();

if (!progressDialog.isShowing()) {

Log.e("Reached", "Here");

if (!preferences.getBoolean("Loggin", false)) {

AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

builder.setTitle("");

builder.setMessage("Enter your current mobile number for verification and learn how to make millions!");

final EditText editText = new EditText(MainActivity.this);

editText.setInputType(InputType.TYPE_CLASS_NUMBER);

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

editText.setLayoutParams(lp);

builder.setView(editText);

builder.setCancelable(false);
builder.setPositiveButton("Ok", new OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {

if (editText.getText().toString() == null && editText.getText().length() == 0) {

Toast.makeText(MainActivity.this, "Please Enter Mobile Number", Toast.LENGTH_LONG)
.show();
} else {

String s = editText.getText().toString();

editor.putString("phoneNo", s);

editor.putBoolean("Loggin", true);
editor.commit();
}

}
});
builder.create().show();
}

}
super.onPageFinished(view, url);
}
});
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {

MainActivity.this.setProgress(progress * 100);

}

});
}

@Override
public void onResume() {
super.onResume();
// Get source of open for app re-engagement
mobileAppTracker.setReferralSources(this);
// MAT will not function unless the measureSession call is included
mobileAppTracker.measureSession();
}
}

Can anyone Help me?

Nadeem Khan

unread,
Nov 26, 2014, 5:13:16 AM11/26/14
to android-...@googlegroups.com
I am also facing same problem. If you have solved it please do help me.
Thanks in advance.
Reply all
Reply to author
Forward
0 new messages