I am trying to use AdvertisingIdClient to fetch the advertisement id of my AIR app. So i did like AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(context)
.
I am not getting any compile time error. I generated ANE
from this. When control encounters this statement, it immediately throws NoClassDefFoundError
. I am not getting what exactly is happening.
Here is my extension code
public class GetAdvertismentID implements FREFunction
{
@Override
public FREObject call(FREContext arg0, FREObject[] arg1)
{
Activity activity = arg0.getActivity();
Context context = activity.getApplicationContext();
String advertId = "initializeByGet\n";
try
{
AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(context);
//if (!adInfo.isLimitAdTrackingEnabled())
//advertId = advertId + adInfo.getId();
} catch(Error e) {
String stackTrace = "";
StackTraceElement[] stackArray = e.getStackTrace();
for(int i = 0; i < stackArray.length; i++)
stackTrace += stackArray[i].toString() + "\n";
advertId += "Error::::::::::::::::";
advertId += "\nLocalized Message : " + e.getLocalizedMessage();
advertId += "\nMessage : " + e.getMessage();
advertId += "\ntoString() : " + e.toString();
advertId += "\nCause : " + e.getCause();
advertId += "\nStack Trace : " + stackTrace;
} catch (Throwable t) {
advertId += "\nThrowable::::::::::::";
advertId += "\nLocalized Message : " + t.getLocalizedMessage();
advertId += "\nMessage : " + t.getMessage();
advertId += "\ntoString() : " + t.toString();
}
try
{
return FREObject.newObject(advertId);
}
catch(Exception e)
{
return null;
}
}
}
When i execute this after generating ANE, i will get this output:
initializeByGet
Error::::::::::::::::
Localized Message : com.google.android.gms.ads.identifier.AdvertisingIdClient
Message : com.google.android.gms.ads.identifier.AdvertisingIdClient
toString() : java.lang.NoClassDefFoundError: com.google.android.gms.ads.identifier.AdvertisingIdClient
Cause : null
Stack Trace : com.games24x7.extension.GetAdvertismentID.call(GetAdvertismentID.java:28)
com.adobe.air.Entrypoints.EntryMainWrapper(Native Method)
com.adobe.air.Entrypoints.EntryMainWrapper(Native Method)
com.adobe.air.Entrypoints.EntryMain(Entrypoints.java:139)
com.adobe.air.AndroidActivityWrapper.LaunchApplication(AndroidActivityWrapper.java:997)
com.adobe.air.AndroidActivityWrapper.onSurfaceInitialized(AndroidActivityWrapper.java:1196)
com.adobe.air.AIRWindowSurfaceView.surfaceChanged(AIRWindowSurfaceView.java:746)
android.view.SurfaceView.updateWindow(SurfaceView.java:554)
android.view.SurfaceView.access$000(SurfaceView.java:81)
android.view.SurfaceView$3.onPreDraw(SurfaceView.java:169)
android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1793)
android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2695)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:156)
android.app.ActivityThread.main(ActivityThread.java:4987)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
dalvik.system.NativeStart.main(Native Method)
I feel the problem here is, it is not able to find the path of some class at runtime. So I tried all the options like: Using the new Android Advertiser id inside an SDK , How do I disable proguard for building my Android app? , http://jmsliu.com/2143/add-admob-ads-in-flash-based-android-apps.html Unfortunately, none of them worked. Please help me if any of you have done this. I am using Flash Builder 4.7 with AIR SDK 14.0.