Build failed (trying to use a .aar)

74 views
Skip to first unread message

Gareth Murfin

unread,
Sep 10, 2019, 12:03:46 PM9/10/19
to CodenameOne Discussions
Hi guys, I am trying to use a .aar for the first time and Im getting build failed. 

I think this is the error:

Merging result: ERROR
/tmp/build8355134923580384042xxx/MyApplication/src/main/AndroidManifest.xml:15:17-46 Error:
Attribute application@label value=(HobMonitor_V1) from AndroidManifest.xml:15:17-46
is also present at [:HobMonitorAlgo:] AndroidManifest.xml:13:9-39 value=(HobMonitorAlgo).
Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:15:3-42:103 to override

Is there any way I can do tools:replace from a build hint to fix this? Or do I need to adjust the .aar ?

Thanks!
Gaz.

Shai Almog

unread,
Sep 10, 2019, 10:35:39 PM9/10/19
to CodenameOne Discussions
Hi,
you can use android.xapplication_attr to inject attributes into the application tag.

Gareth Murfin

unread,
Sep 16, 2019, 12:10:47 PM9/16/19
to CodenameOne Discussions
Thanks Shai, it compiles fine now, but I cant work out how to call the code. The .aar contains a class called "AlgorithmCWrapper" but I cannot seem to import it (ive done a cn1lib refresh).. the interface in the c looks like below...

So I expected to be able to do AlgorithmCWrapper cwrap = new AlgorithmCWrapper(); 
or maybe
AlgorithmCWrapper my = NativeLookup.create(AlgorithmCWrapper.class);

but AlgorithmCWrapper doesnt import. Ive done this quite a few times but I can't see my old code because I'm travelling. How would I get it to work?

package uk.co.skyrad.hobmonitoralgo;

public class AlgorithmCWrapper {
    static {
        System.loadLibrary("hobmonitor");
    }

    public native void set_input(byte[] packedBluetoothData, byte hobLayoutId);
    public native int[] get_pan_indexes();
    public native float[] get_pan_temperatures();
    public native int[] get_pan_states();
    public native int[] get_pan_boiling_time_seconds();
    public native int[] get_time_since_food_added_seconds();
    public native void init();
    public native void step();
}

Shai Almog

unread,
Sep 17, 2019, 1:34:06 AM9/17/19
to CodenameOne Discussions
It won't import in the IDE but it should work when you compile in the build cloud. The best way to get this working is send a build with include source and edit the native class in Android Studio then copy/paste the code from there.

Gareth Murfin

unread,
Sep 17, 2019, 1:03:05 PM9/17/19
to CodenameOne Discussions
Ohhh yes.. thanks again Shai, great support.

Gareth Murfin

unread,
Sep 17, 2019, 1:34:28 PM9/17/19
to CodenameOne Discussions

There seems to be issues with the Android Studios project:

ERROR: Could not determine the class-path for class com.android.tools.idea.gradle.project.sync.ng.SyncAction.

And after cleaning and trying again I keep seeing

Build script error, unsupported Gradle DSL method found: 'google()'!

Possible causes could be:  
  - you are using Gradle version where the method is absent (Fix Gradle settings)
  - you didn't apply Gradle plugin which provides the method (Apply Gradle plugin)
  - or there is a mistake in a build script (Goto source)
Open File


FInally shouldnt it use SDK28 foro google play? seems to be on 27.

None of this would matter if I could test the .arr in the project but I cannot compile, and anything I type is considered "OK" by Android Studio. ANy ideas how I get a proper working AS project?

Shai Almog

unread,
Sep 17, 2019, 10:51:05 PM9/17/19
to CodenameOne Discussions

Gareth Murfin

unread,
Sep 18, 2019, 9:58:31 AM9/18/19
to CodenameOne Discussions
Thanks Shai, which bit in particular? this? android.enableAapt2=false

Similar error:
Could not determine the class-path for class org.jetbrains.plugins.gradle.model.ProjectImportAction.

going to try upgrading AS.

On Wednesday, September 18, 2019 at 3:51:05 AM UTC+1, Shai Almog wrote:

Gareth Murfin

unread,
Sep 18, 2019, 10:33:27 AM9/18/19
to CodenameOne Discussions
Upgrading did no good still getting errors. 

15:31 Gradle sync started with IDEA sync

15:31 Gradle sync failed: Could not determine the class-path for class org.jetbrains.plugins.gradle.model.ProjectImportAction.
Consult IDE log for more details (Help | Show Log) (11 s 72 ms)

15:31 NDK Resolution Outcome: Project settings: Gradle model version=1.12, NDK version is UNKNOWN

Shai Almog

unread,
Sep 18, 2019, 10:20:44 PM9/18/19
to CodenameOne Discussions
Make sure to use Gradle 4.6 and define it in intellij as explained there. Try using AS 3.2 which should generally work.

Gareth Murfin

unread,
Sep 19, 2019, 2:15:44 PM9/19/19
to CodenameOne Discussions
thanks shai, I just wrote the code i needed in a standalone android studio project then copied it into my native interface so its ok now.
Reply all
Reply to author
Forward
0 new messages