Java Question play services - old jar vs new Maven repository

Johan Schoeman

Expert
Licensed User
Longtime User
I am stuck with google play services. I am trying to wrap a project (OCR) making use of google play services. The old google-play-services.jar contains some classes that needs to be used while the jar inside play-services-vision-9.4.0.aar (when unzipping and looking into classes.jar) contains some of the other classes that needs to be used. So, some of the classes appear in either one or the other but not in both.

How do I incorporate this into the wrapper?
 

Johan Schoeman

Expert
Licensed User
Longtime User
I am stuck with google play services. I am trying to wrap a project (OCR) making use of google play services. The old google-play-services.jar contains some classes that needs to be used while the jar inside play-services-vision-9.4.0.aar (when unzipping and looking into classes.jar) contains some of the other classes that needs to be used. So, some of the classes appear in either one or the other but not in both.

How do I incorporate this into the wrapper?
OK - I found all the new ones that I need (extracted the classes.jar from the .aar files):
play-services-basement-9.4.0.jar
play-services-base-9.4.0.jar
play-services-vision-9.4.0.jar

I have now copied all these jars into the libs folder of my library and also into my additional library folder. The library compiles 100% but when I start the scan I get the following error:

B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
java.lang.RuntimeException: Unable to start activity ComponentInfo{JHS.AndroidVisionMaster/com.google.android.gms.samples.vision.ocrreader.OcrCaptureActivity}: android.content.res.Resources$NotFoundException: File res/drawable-v19/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2412)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
    at android.app.ActivityThread.access$900(ActivityThread.java:174)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5593)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v19/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
    at android.content.res.Resources.loadDrawable(Resources.java:3443)
    at android.content.res.Resources.getDrawable(Resources.java:1921)
    at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
    at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
    at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
    at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83)
    at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146)
    at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28)
    at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
    at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
    at com.google.android.gms.samples.vision.ocrreader.OcrCaptureActivity.onCreate(OcrCaptureActivity.java:85)
    at android.app.Activity.performCreate(Activity.java:5458)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
    ... 11 more
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:986)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930)
    at android.content.res.Resources.loadDrawable(Resources.java:3439)
    ... 30 more
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **

The @DependOn in my wrapper looks as follows:
B4X:
@DependsOn(values={"android-support-design", "android-support-v7-appcompat", "android-support-v4", "play-services-vision-9.4.0", "play-services-basement-9.4.0", "play-services-base-9.4.0"})

The last 3 are the .aar files that are now in my additional library folder. I have renamed the classes.jar files extracted from each of the .aar files to have exactly the same name (except they are now called play-services-vision-9.4.0.jar, play-services-basement-9.4.0.jar, and play-services-base-9.4.0.jar) and have copied them also into my additional library folder. Is that correct in other words having the .aar files and the jars extracted from the .aar files both in the additional library folder (with the same names except for the .aar and .jar extensions)?
 

DonManfred

Expert
Licensed User
Longtime User
i guess the packages in depends on should look like this

B4X:
@DependsOn(values={"com.android.support:appcompat-v7", "com.android.support:support-v4", "com.google.android.gms:play-services-vision"})

you should addition use the designsupport 2.0 library and appcompat lib 3.2+ insideyour b4a project i guess to include the support design classes....
 

DonManfred

Expert
Licensed User
Longtime User
Is that correct in other words having the .aar files and the jars extracted from the .aar files both in the additional library folder (with the same names except for the .aar and .jar extensions)?
that sounds wrong for me... you need to have them to compile with slc.
But you dont need to put the extracted jar to additional libs folder. Instead you should use dependson in your wrapper to tell b4a which AAR is needed. See my previous answer
 

Johan Schoeman

Expert
Licensed User
Longtime User
that sounds wrong for me... you need to have them to compile with slc.
But you dont need to put the extracted jar to additional libs folder. Instead you should use dependson in your wrapper to tell b4a which AAR is needed. See my previous answer
What about @Erel's answer here about referencing the .aar in the @DependsOn? How does that fit in with...
@DependsOn(values={"com.android.support:appcompat-v7", "com.android.support:support-v4", "com.google.android.gms:play-services-vision"})
 

Johan Schoeman

Expert
Licensed User
Longtime User

DonManfred

Expert
Licensed User
Longtime User
Everything what is included in the google maven repo needs to be referenced like i posted.
If you have a additional aar to incude you need to use
B4X:
@DependsOn(values={"filenameofaarfile.aar"})
inside the dependson and add the aar to your distribution. This file needs to be copied inside additional libs folder.

See for example my lastest wrap. the SpaceNavigation.

I´m using this dependson
B4X:
@DependsOn(values={"SpaceNavigation.aar","com.android.support:support-v4"})
 
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Everything what is included in the google maven repo needs to be referenced like i posted.
If you have a additional aar to incude you need to use
B4X:
@DependsOn(values={"filenameofaarfile.aar"})
inside the dependson and add the aar to your distribution. This file needs to be copied inside additional libs folder.

See for example my lastest wrap. the SpaceNavigation.

I´m using this dependson
B4X:
@DependsOn(values={"SpaceNavigation.aar","com.android.support:support-v4"})
No joy with the OCR sample whatsoever. Have spent too much time on this already (for a weekend hobby) without any success and have sent it to the rubbish bin to stay there for eternity...
 
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Everything what is included in the google maven repo needs to be referenced like i posted.
If you have a additional aar to incude you need to use
B4X:
@DependsOn(values={"filenameofaarfile.aar"})
inside the dependson and add the aar to your distribution. This file needs to be copied inside additional libs folder.

See for example my lastest wrap. the SpaceNavigation.

I´m using this dependson
B4X:
@DependsOn(values={"SpaceNavigation.aar","com.android.support:support-v4"})
Hi Manfred

I have taken it out of the rubbish bin, dusted it off and will try this again. A question or two:
1. In your @DependsOn(values={"SpaceNavigation.aar","com.android.support:support-v4"}) - is the "com.android.support:support-v4" coming from the new Maven repository or does it refer to the the old android-support-v4.jar that was originally in your additional libs folder?
2. If it is from the new Maven repository - do we then need to copy the applicable .aar file into our additional library folder?
3. Referring to .aar files in the @DependsOn - is this only for .aar files other than what is in the Maven repository?

Thanks

Johan
 

DonManfred

Expert
Licensed User
Longtime User
is the "com.android.support:support-v4" coming from the new Maven repository
Yes. MAVEN Repo if you reference it THIS way.

2. If it is from the new Maven repository - do we then need to copy the applicable .aar file into our additional library folder?
Everything what is in the maven repo does NOT need to exists in Additional Libs folder.
3. Referring to .aar files in the @DependsOn - is this only for .aar files other than what is in the Maven repository?
Yes. See my wrap for the Space-Navigation. this is a good example for this situation. It references android support v4 (maven) and also an additional aar (SpaceNavigation.aar) which NEED to be copied to additional libs folder
In fact: for this lib you need to copy aar, jar and xml file to additional libs folder
 

Johan Schoeman

Expert
Licensed User
Longtime User
Yes. MAVEN Repo if you reference it THIS way.


Everything what is in the maven repo does NOT need to exists in Additional Libs folder.

Yes. See my wrap for the Space-Navigation. this is a good example for this situation. It references android support v4 (maven) and also an additional aar (SpaceNavigation.aar) which NEED to be copied to additional libs folder
Thanks Manfred - will give it a go based on your answers!
 

Johan Schoeman

Expert
Licensed User
Longtime User
Just my own "at-this-stage-very-negative" opinion. I think it is a mess of note. Just to try and find what class resides where is a mission in itself. The old SDK was just MILES easier and miles better. Interest at present to continue with this is just about nothing..
 
Top