deckameron / Ti.Android.Admob

Appcelerator Android module wrapping Admob functionalities
17 stars 7 forks source link

Error with Ti.Android.Admob and Ti.cloudpush #2

Closed albwebbergate closed 7 years ago

albwebbergate commented 7 years ago

Hi @deckameron I tried to use your module to implement intertstitial ads on my app compiled with titanium sdk 5.5.1.GA. I include

<modules>
        <module platform="commonjs">ti.cloud</module>
        <module platform="android">ti.imagefactory</module>
        <module platform="android">ti.cloudpush</module>
        <module platform="android">com.rkam.swiperefreshlayout</module>
        <module platform="android">ti.inappbilling</module>
        <module platform="android">ti.android.admob</module>
</modules>

ti.cloudpush version 3.4.1 ti.android.admob version 1.0

this is my tiapp.xml

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest android:versionCode="xx" android:versionName="xx">
            <uses-sdk android:maxSdkVersion="23"
                android:minSdkVersion="16" android:targetSdkVersion="23"/>
            <uses-permission android:name="com.android.vending.BILLING"/>
            <application android:theme="@style/Theme.NoActionBar"/>
            <application android:debuggable="false"
                android:icon="@drawable/appicon" android:theme="@style/Theme.NoActionBar">
                <activity
                    android:configChanges="keyboardHidden|orientation|screenSize"
                    android:label="@string/app_name"
                    android:name=".xxxx"
                    android:screenOrientation="portrait" android:theme="@style/Theme.NoActionBar">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN"/>
                        <category android:name="android.intent.category.LAUNCHER"/>
                    </intent-filter>
                </activity>
                <activity
                    android:configChanges="keyboardHidden|orientation|screenSize"
                    android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="portrait"/>
                <activity
                    android:configChanges="keyboardHidden|orientation|screenSize"
                    android:name="org.appcelerator.titanium.TiTranslucentActivity"
                    android:screenOrientation="portrait" android:theme="@style/Theme.NoActionBar"/>
                <service android:exported="false" android:name="com.appcelerator.analytics.APSAnalyticsService"/>
                <meta-data android:name="com.google.android.gms.version" android:value="9683000"/>
                <activity
                    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.android.gms.ads.AdActivity"/>
            </application>
        </manifest>
    </android>

but when i compile the app the console gave me this error

[ERROR] :  Conflicting jar files detected:
[ERROR] :  
[ERROR] :  The following modules have different "google-play-services-base.jar" files
[ERROR] :     ti.cloudpush       (version 3.4.1) (hash=68b48e0a3cb3582bd4ab0bb00625b83a)
[ERROR] :     ti.android.admob   (version 1.0) (hash=730a1d6196847cb5b1067ac02a875876)
[ERROR] :  
[ERROR] :  You can either select a version of these modules where the conflicting jar file is the same or you
[ERROR] :  can try copying the jar file from one module's "lib" folder to the other module's "lib" folder.

So I removed google-play-services-base.jar from the ti.cloudpush module (I removed also google-play-services-gcm.jar cause a subsequent error). After that the compile works but when the app launched the console log

[ERROR] :  GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
[ERROR] :  TiApplication: (main) [40,5804] Sending event: exception on thread: main msg:java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 9683000 but found 7571000.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />; Titanium 5.5.1,2016/09/27 05:39,b18727f
[ERROR] :  TiApplication: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 9683000 but found 7571000.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
[ERROR] :  TiApplication:   at com.google.android.gms.common.zze.zzbt(Unknown Source)
[ERROR] :  TiApplication:   at com.google.android.gms.common.zze.isGooglePlayServicesAvailable(Unknown Source)
[ERROR] :  TiApplication:   at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
[ERROR] :  TiApplication:   at com.appcelerator.aps.CCPushService.registerGCM(CCPushService.java:316)
[ERROR] :  TiApplication:   at com.appcelerator.aps.APSCloudPush$2.onReceived(APSCloudPush.java:1030)
[ERROR] :  TiApplication:   at com.appcelerator.aps.CCPushService$1.onPostExecute(CCPushService.java:116)
[ERROR] :  TiApplication:   at com.appcelerator.aps.CCPushService$1.onPostExecute(CCPushService.java:95)
[ERROR] :  TiApplication:   at android.os.AsyncTask.finish(AsyncTask.java)
[ERROR] :  TiApplication:   at android.os.AsyncTask.access$500(AsyncTask.java)
[ERROR] :  TiApplication:   at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java)
[ERROR] :  TiApplication:   at android.os.Handler.dispatchMessage(Handler.java)
[ERROR] :  TiApplication:   at android.os.Looper.loop(Looper.java)
[ERROR] :  TiApplication:   at android.app.ActivityThread.main(ActivityThread.java)
[ERROR] :  TiApplication:   at java.lang.reflect.Method.invoke(Native Method)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)

You know some incompatibilities with this two module. I launched my app on my LG G3 with Android 6.0 Marshmallow.

What's the matter? I put something wrong in the tiapp.xml?

Thank you, Alberto

deckameron commented 7 years ago

Hi @albwebbergate !

This is a very old issue with Titanium and the ONLY solution I could find. It's Proguard! It is really simple and easy to use (in this case) and the tutorial is here.

The new Titanium SDK 6.0.0 solves this issue, but since you are using 5.5.1, you will have to use Proguard to string Google Play Services the right way.

Let me know if it worked for you! :-)

albwebbergate commented 7 years ago

This is a very old issue with Titanium and the ONLY solution I could find. It's Proguard! It is really simple and easy to use (in this case) and the tutorial is here. ... Let me know if it worked for you! :-)

I installed Proguard and I follow the tutorial but I'm not able to make it work (maybe I made some mistake following the tutorial). In the end I was able to make my app work by change the module that I use to retrive the device token on Android, I switched from ti.cloudpush to nl.vanvianen.android.gcm.

Thank you, Alberto

deckameron commented 7 years ago

I am glad to know you found a solution! ;-)