Giter VIP home page Giter VIP logo

Comments (18)

pozirk avatar pozirk commented on September 15, 2024

Hey!
Sorry, I can't really remember. :(
It's possible, that I made .zip myself combining classes from several .jar files.

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

Thanks to reply.

I tried this option, but the error remains. The error happens after the splash screen from Harman.

I need to solve this problem to publish my game, I don't want to buy the ANE, but maybe it will be necessary.

If I find a solution I will improve your ANE with this update. Anyway, thank you!

from aneadmob.

pozirk avatar pozirk commented on September 15, 2024

I don't know why I uploaded .zip file, but looks like you actually need a .jar.
Check .classpath file:
<classpathentry kind="lib" path="libs/google-play-services.jar"/>

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

Indeed. It is necessary to merge both: your java code with this jar. You wrote this .bat file:

xcopy android\AdMob\bin\classes android\AdMob\bin /S /Y /R

rd android\AdMob\bin\classes /S /Q

"c:\Program Files (x86)\Java\jdk1.8.0_201\bin\jar.exe" cvf android/AdMob/build/libAdMob.jar -C android/AdMob/bin .

I will try to rebuild your code with Android Studio add this jar, merge them, generate the ANE again and check if it will work

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

I opened your code with Android Studio, renamed your google-play-services.zip to jar and added it to the project. I also added the FlashRuntimeExtensions.jar with gradle


dependencies {
    implementation files('C:\\dev\\AIR\\ane\\ANEAdMob-master\\android\\AdMob\\libs\\google-play-services.jar')
    implementation files('C:\\dev\\AIR\\AIRSDK_Windows\\lib\\android\\FlashRuntimeExtensions.jar')
}

and I changed the application to library with this code

apply plugin: 'com.android.library'

I built the project and it generated an AAR file. (See How to build ANE in Android Studio ) It is also a zip, so I extracted it to a folder and took the classes.jar. So, with classes.jar and google-play-services.jar I merge them into a single jar and generated the ANE using the adt.bat from AIR.

When I ran the game, after the splash screen, the same error :(

So, my process is wrong

from aneadmob.

pozirk avatar pozirk commented on September 15, 2024

I think your final classes.jar file should be the same as mine build/libAdMob.jar.
In my case ANE was made with Eclipse, and after they switched to Android Studio, I kind of gave up on keeping it up to date.
So, process is different now.

Check that you have all the .class files in your .aar file.
Should be both my .class files (bin\com\pozirk\ads\admob\AdMobListener.class, etc.) as well as google class files (bin\com\google\ads\AdRequest.class, etc.).

Also build.bat will be different, no need to build libAdMob.jar:

del android\AdMob\build\libAdMob.jar
del AdMob.ane

SET PLATFORM_ANDROID= -platform Android-ARM -C android\AdMob\build\ .
SET PLATFORM_DEFAULT= -platform default -C default\ .

"airsdk33\bin\adt.bat" -package -target ane AdMob.ane air\extension.xml -swc air/AdMob/bin/AdMob.swc %PLATFORM_ANDROID% %PLATFORM_DEFAULT%

And your extension.xml has the following that might need to be updated:
<nativeLibrary>libAdMob.jar</nativeLibrary>

Have you tried to build some sample ANE first?

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

Sorry. My last test I pointed the project to the old version of the ANE, the error was different. The game works but the ANE raises a null pointer because the AdmobMananer is null. I catch this error and display on the game screen.

Yes I did some samples.

I will work more with this this and I will post here later.

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

Hi. (My English is rusty)

I was able to build your code using Android Studio with Gradle. First I used your google-play-services.jar
I had some troubles with cache using Adobe Animate to build the apk and also with the way your code access the AdMobManager instance inside the class ExtensionContext it was generating a NullPointException.

To fix this I changed the attribute _adMobMan from ExtensionContext to private and I changed it to be a singleton, this way:


private AdMobManager _adMobMan;
public AdMobManager getAdMobMan() {
  	if(_adMobMan==null) {
  		_adMobMan = new AdMobManager(this.getActivity(), this);
	}
		return _adMobMan;
	}

It worked. The process to build the AAR doesn't generate the .class files for the dependency. So I had to extract the AAR to a folder, get the classes.jar and merge it with the google-play-services.jar in a single JAR. Finally I built the ANE with adt

Now I will step forward.

from aneadmob.

pozirk avatar pozirk commented on September 15, 2024

Wow, amazing!
You need the latest version of google play services, to have Rewarded Ads.
And also some code modifications, as starting from version 17, I believe, you need to provide App ID.

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

We have 2 ways to use Admob, with Firebase or without firebase.

The first, with Firebase, requires a google-services.json inside the project and it contains a list of data including the APP ID. The second I think will not require this .json, but both uses the app id inside Manifest, like this:


<manifest>
    <application>
        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
    </application>
</manifest>

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

When I use the Admob version 11.0.2, everything works fine with AndroidStudio and Gradle

apply plugin: 'com.android.library'
apply plugin: 'com.kezong.fat-aar'

android {
    compileSdkVersion 28
    buildToolsVersion "30.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
    }
}

configurations.embed.transitive = true 

dependencies {
    implementation files("$System.env.AIR_HOME/lib/android/FlashRuntimeExtensions.jar")
    embed 'com.google.android.gms:play-services-ads:11.0.2' // 👍 

}

But when I update Admob to the last version, currently 19.3.0, the game crashes after splash screen.

apply plugin: 'com.android.library'
apply plugin: 'com.kezong.fat-aar'

android {
    compileSdkVersion 28
    buildToolsVersion "30.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
    }
}

configurations.embed.transitive = true //this is necessary to export all dependencies using FAT-AAR plugin

dependencies {
    implementation files("$System.env.AIR_HOME/lib/android/FlashRuntimeExtensions.jar")
    embed 'com.google.android.gms:play-services-ads:19.3.0'  //   CRASH!  👎 java.lang.NoClassDefFoundError: com.google.android.gms.common.R$string

}

This is the Log extracted with the StackTrace:


2020-07-29 14:52:47.434 12733-12795/? E/AndroidRuntime: FATAL EXCEPTION: Thread-12
    Process: air.br.com.hastatus.subwaymonstersinvasion, PID: 12733
    java.lang.NoClassDefFoundError: com.google.android.gms.common.R$string
        at com.google.android.gms.common.api.internal.GoogleServices.<init>(Unknown Source:3)
        at com.google.android.gms.common.api.internal.GoogleServices.initialize(Unknown Source:44)
        at com.google.android.gms.internal.measurement.zzx.zzf(com.google.android.gms:play-services-measurement-sdk-api@@17.1.0:44)
        at com.google.android.gms.internal.measurement.zzx.<init>(com.google.android.gms:play-services-measurement-sdk-api@@17.1.0:22)
        at com.google.android.gms.internal.measurement.zzx.zza(com.google.android.gms:play-services-measurement-sdk-api@@17.1.0:6)
        at com.google.android.gms.measurement.api.AppMeasurementSdk.getInstance(com.google.android.gms:play-services-measurement-sdk-api@@17.1.0:2)
        at com.google.android.gms.internal.ads.zzamm.zze(com.google.android.gms:play-services-ads-lite@@19.3.0:41)
        at com.google.android.gms.internal.ads.zzaml.run(Unknown Source:4)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/pozirk/ads/admob/R$string;
        at com.google.android.gms.common.R$string.<clinit>(R.java:8)
        at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(Unknown Source:8)
        at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(Unknown Source:5)
        at com.google.android.gms.internal.ads.zzbat.zzd(com.google.android.gms:play-services-ads-lite@@19.3.0:67)
        at com.google.android.gms.internal.ads.zzwf.zzd(com.google.android.gms:play-services-ads-lite@@19.3.0:35)
        at com.google.android.gms.internal.ads.zzyv.zzg(com.google.android.gms:play-services-ads-lite@@19.3.0:160)
        at com.google.android.gms.internal.ads.zzyv.zza(com.google.android.gms:play-services-ads-lite@@19.3.0:18)
        at com.google.android.gms.ads.MobileAds.initialize(com.google.android.gms:play-services-ads-lite@@19.3.0:6)
        at com.google.android.gms.ads.MobileAds.initialize(com.google.android.gms:play-services-ads-lite@@19.3.0:8)
        at com.pozirk.ads.admob.manager.AdMobManager.<init>(AdMobManager.java:47)
        at com.pozirk.ads.admob.context.ExtensionContext.getAdMobMan(ExtensionContext.java:60)
        at com.pozirk.ads.admob.function.InitFunction.call(InitFunction.java:33)
        at com.adobe.air.Entrypoints.EntryMainWrapper(Native Method)
        at com.adobe.air.Entrypoints.EntryMain(Entrypoints.java:143)
        at com.adobe.air.AndroidActivityWrapper.LaunchApplication(AndroidActivityWrapper.java:1189)
        at com.adobe.air.AndroidActivityWrapper.launchApplication(AndroidActivityWrapper.java:1472)
        at com.adobe.air.AndroidActivityWrapper$1.run(AndroidActivityWrapper.java:1452)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:6878)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.pozirk.ads.admob.R$string" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/air.br.com.hastatus.subwaymonstersinvasion-D7WRBiOy1DKK5puXV9pcSg==/base.apk"],nativeLibraryDirectories=[/data/app/air.br.com.hastatus.subwaymonstersinvasion-D7WRBiOy1DKK5puXV9pcSg==/lib/arm64, /data/app/air.br.com.hastatus.subwaymonstersinvasion-D7WRBiOy1DKK5puXV9pcSg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.google.android.gms.common.R$string.<clinit>(R.java:8) 
        at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(Unknown Source:8) 
        at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(Unknown Source:5) 
        at com.google.android.gms.internal.ads.zzbat.zzd(com.google.android.gms:play-services-ads-lite@@19.3.0:67) 
        at com.google.android.gms.internal.ads.zzwf.zzd(com.google.android.gms:play-services-ads-lite@@19.3.0:35) 
        at com.google.android.gms.internal.ads.zzyv.zzg(com.google.android.gms:play-services-ads-lite@@19.3.0:160) 
        at com.google.android.gms.internal.ads.zzyv.zza(com.google.android.gms:play-services-ads-lite@@19.3.0:18) 
        at com.google.android.gms.ads.MobileAds.initialize(com.google.android.gms:play-services-ads-lite@@19.3.0:6) 
        at com.google.android.gms.ads.MobileAds.initialize(com.google.android.gms:play-services-ads-lite@@19.3.0:8) 
        at com.pozirk.ads.admob.manager.AdMobManager.<init>(AdMobManager.java:47) 
        at com.pozirk.ads.admob.context.ExtensionContext.getAdMobMan(ExtensionContext.java:60) 
        at com.pozirk.ads.admob.function.InitFunction.call(InitFunction.java:33) 
        at com.adobe.air.Entrypoints.EntryMainWrapper(Native Method) 
        at com.adobe.air.Entrypoints.EntryMain(Entrypoints.java:143) 
        at com.adobe.air.AndroidActivityWrapper.LaunchApplication(AndroidActivityWrapper.java:1189) 
        at com.adobe.air.AndroidActivityWrapper.launchApplication(AndroidActivityWrapper.java:1472) 
        at com.adobe.air.AndroidActivityWrapper$1.run(AndroidActivityWrapper.java:1452) 
        at android.os.Handler.handleCallback(Handler.java:873) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:6878) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876) 
2020-07-29 14:52:47.445 1923-4464/? W/ActivityManager:   Force finishing activity air.br.com.hastatus.subwaymonstersinvasion/.AppEntry

from aneadmob.

pozirk avatar pozirk commented on September 15, 2024

How do you do the upgrade? Where did you get your google-play-services.jar?
I can't remember where I picked mine. :)
Most likely some classes are missing.

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

I will create a pull request

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

You can check my changes here:

https://github.com/luc4smoreira/ANEAdMob

Now gradle will download and install the dependency from Google's Maven. It's not necessary to use the google-play-services.jar. You just set the version.

The process to generate the libAdMob.jar this way is a little tricky. I'm using the plugin FAT-AAR to export the dependencies with the AAR file.

from aneadmob.

pozirk avatar pozirk commented on September 15, 2024

So, is it working with the latest google play services?

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

I closed the issue because it was only a question about the dependency.

So, I created a pull request, you can see the list with new features there. Check it out.

from aneadmob.

pozirk avatar pozirk commented on September 15, 2024

Great, is your version working?
I can't accept pull request for not working ANE.

from aneadmob.

luc4smoreira avatar luc4smoreira commented on September 15, 2024

Yes, it is working.

from aneadmob.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.