Trouble getting generated apk to run

25 views
Skip to first unread message

markus.wiesenbacher

unread,
Jun 10, 2015, 2:12:55 PM6/10/15
to maven-androi...@googlegroups.com
Hi guys,

I am a Android-newbie and have some silly questions, here is what I want to do:

I want to run a message broker service (Apache Kafka, which includes Zookeeper, Scala, ...) on a modern Android-device. Compilation works, also the apk-generation, but I face some issues:

- My app crashes as soon as a method from any of the maven deps is invoked
- Every maven dependency seems to get converted into the .dex-files. Is this necessary or can they be added to the apk as they are (jars)?
- I´ve found a folder "unpacked-embedded-jars" in the apk, containing a single jar (which is originally a dependency). What is this for?

Here is the config from my pom.xml:









                        <plugin>


                                <groupId>com.simpligility.maven.plugins</groupId>


                                <artifactId>android-maven-plugin</artifactId>


                                <configuration>


                                        <sdk>


                                                <platform>22</platform>


                                        </sdk>


                                        <emulator>


                                                <avd>Device</avd>


                                                <wait>120000</wait>


                                                <options>-no-skin</options>


                                        </emulator>


                                        <dex>


                                                <jvmArguments>


                                                        <jvmArgument>-Xms256m</jvmArgument>


                                                        <jvmArgument>-Xmx4096m</jvmArgument>


                                                </jvmArguments>


                                                <multiDex>true</multiDex>


                                               


<!--


                                                <coreLibrary>true</coreLibrary>


                                                <noLocals>false</noLocals>


                                                <optimize>true</optimize>


-->


                                                <!--<predex>path to predexed libraries, defaults to target/dexedLibs</predex>-->


                                        </dex>


                                        <attachJar>false</attachJar>


                                        <sign><debug>false</debug></sign>


                                        <extractDuplicates>true</extractDuplicates>


<!--


                                        <deleteConflictingFiles>true</deleteConflictingFiles>


                    <undeployBeforeDeploy>true</undeployBeforeDeploy>


-->


                    <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>


                    <resourceDirectory>${project.basedir}/res</resourceDirectory>


                    <assetsDirectory>${project.basedir}/assets</assetsDirectory>


                </configuration>


                        </plugin>


Many thanks in advance!

Markus

Manfred Moser

unread,
Jun 10, 2015, 3:07:26 PM6/10/15
to maven-androi...@googlegroups.com


markus.wiesenbacher wrote on 10.06.2015 02:45:

> Hi guys,
>
>
> I am a Android-newbie and have some silly questions, here is what I want to do:
>
>
> I want to run a message broker service (Apache Kafka, which includes Zookeeper, Scala, ...) on a modern Android-device. Compilation works, also the apk-generation, but I face some issues:

This might be quite difficult to get going since there is large set of dependencies required and you might run into issues with method numbers and apk size.


> - My app crashes as soon as a method from any of the maven deps is invoked


>
> - Every maven dependency seems to get converted into the .dex-files. Is this necessary or can they be added to the apk as they are (jars)?

No.. it has to be dex. The Android runtime does not understand the class file format.

> - I扉e found a folder "unpacked-embedded-jars" in the apk, containing a single jar (which is originally a dependency). What is this for?

Hm.. thats looks like a bug.

I see you are using multidex... not sure about the full details on that as I have not used it.

You might also need to use proguard to reduce size.

manfred

Markus Wiesenbacher

unread,
Jun 11, 2015, 1:30:01 AM6/11/15
to maven-androi...@googlegroups.com
HI Manfred,

thanks for your quotes!

The APK gets built, it´s size is around 6MB and can be installed successfully. I can call methods of an included dep, but at a certain point it crashes and I don´t know why. This always happens if I call something from another dep. Do you have any suggestions, maybe there is something missing?

Thanks!
Markus

-----Ursprüngliche Nachricht-----
Von: maven-androi...@googlegroups.com [mailto:maven-androi...@googlegroups.com] Im Auftrag von Manfred Moser
Gesendet: Mittwoch, 10. Juni 2015 21:07
An: maven-androi...@googlegroups.com
Betreff: Re: [maven-android-developers] Trouble getting generated apk to run
--
You received this message because you are subscribed to the Google Groups "Maven Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-deve...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Manfred Moser

unread,
Jun 12, 2015, 1:35:57 PM6/12/15
to maven-androi...@googlegroups.com
There is probably some issue with some of the transitive dependencies. They might even be masked by things included in Android itself. You will have to debug the apk and find the exact location where it crashes out.

manfred

'Markus Wiesenbacher' via Maven Android Developers wrote on 10.06.2015 22:29:

> HI Manfred,
>
> thanks for your quotes!
>
> The APK gets built, it´s size is around 6MB and can be installed successfully.
> I can call methods of an included dep, but at a certain point it crashes and I
> don´t know why. This always happens if I call something from another dep. Do
> you have any suggestions, maybe there is something missing?
>
> Thanks!
> Markus
>
> -----Ursprüngliche Nachricht-----
> Von: maven-androi...@googlegroups.com
> [mailto:maven-androi...@googlegroups.com] Im Auftrag von Manfred Moser
> Gesendet: Mittwoch, 10. Juni 2015 21:07
> An: maven-androi...@googlegroups.com
> Betreff: Re: [maven-android-developers] Trouble getting generated apk to run
>
>
>

Markus Wiesenbacher

unread,
Jun 14, 2015, 3:42:48 PM6/14/15
to maven-androi...@googlegroups.com
Is there any chance to check what´s included in the APK, something like a manifest?

Thanks
Markus ;)

-----Ursprüngliche Nachricht-----
Von: maven-androi...@googlegroups.com [mailto:maven-androi...@googlegroups.com] Im Auftrag von Manfred Moser
Gesendet: Freitag, 12. Juni 2015 19:36
An: maven-androi...@googlegroups.com
Betreff: Re: AW: [maven-android-developers] Trouble getting generated apk to run

Fredrik Jonson

unread,
Jun 15, 2015, 3:51:02 AM6/15/15
to 'Markus Wiesenbacher' via Maven Android Developers
On 2015-06-14 at 21:42, maven-androi...@googlegroups.com wrote:

> Is there any chance to check what´s included in the APK, something like
> a manifest?

Yes, the apk is just a zip-file, so you can just unzip it. The classes and all
dependencies are in the file classes.dex, which is in the dex file format. You
can use the dex2jar tool to check what's inside.

We're going a bit of topic here but a word of advice:

If the developers of Zookeeper and Kafka doesn't explicitly say that their code
is designed to work on Android, it is very likely that they use Java SE api:s
that does not exist on Android. Remember, the Android runtime isn't a Java
Virtual Machine. Android simply uses Java, the programming language, to
implement their own standard library, which partially mirrors the behavior of a
subset of the Java standard library. Same same, but different.

I didn't see which message broker you're trying to use? If that also is a open
source project, you can probably reach out on their mailing list to get some
advice on the likelyhood on using it on Android.

Personally, I would have written a simple REST service for the clients to use
to produce and consume messages (or use GCM if you want to rely on Google),
and opted for a simpler IPC method for in app coordination. Though maybe that's
not your goal?

--
Fredrik Jonson

Markus Wiesenbacher

unread,
Jun 18, 2015, 6:08:28 AM6/18/15
to maven-androi...@googlegroups.com
Thanks for your quotes, I did make some advances:

I moved from Kafka to ActiveMQ, and have a simple project which has a single broker-lib as dependency. This broker-lib has some transitive dependencies, which get all compiled into the dex/apk with you superb working android-maven-plugin. But:

LogCat logs an exception, saying "Caused by: java.lang.NoClassDefFoundError: org.apache.activemq.command.ActiveMQTopic"

This class is originally in a transitive dependency, and I checked that with dex2jar: It´s included in the dex!

Do you have any hints why this class is not found? Do I miss a compile-option for the android-maven-plugin?

Many thanks ... ;)
Markus

-----Ursprüngliche Nachricht-----
Von: maven-androi...@googlegroups.com [mailto:maven-androi...@googlegroups.com] Im Auftrag von Fredrik Jonson
Gesendet: Montag, 15. Juni 2015 09:51
An: 'Markus Wiesenbacher' via Maven Android Developers
Betreff: Re: AW: [maven-android-developers] Trouble getting generated apk to run

Manfred Moser

unread,
Jun 18, 2015, 4:57:36 PM6/18/15
to maven-androi...@googlegroups.com
Why are you just trying with another framework that doesnt work on Android (ActiveMQ) ?

What are you actually trying to do? What are you looking for?

manfred

'Markus Wiesenbacher' via Maven Android Developers wrote on 18.06.2015 03:08:

> Thanks for your quotes, I did make some advances:
>
> I moved from Kafka to ActiveMQ, and have a simple project which has a single
> broker-lib as dependency. This broker-lib has some transitive dependencies,
> which get all compiled into the dex/apk with you superb working
> android-maven-plugin. But:
>
> LogCat logs an exception, saying "Caused by: java.lang.NoClassDefFoundError:
> org.apache.activemq.command.ActiveMQTopic"
>
> This class is originally in a transitive dependency, and I checked that with
> dex2jar: It´s included in the dex!
>
> Do you have any hints why this class is not found? Do I miss a compile-option
> for the android-maven-plugin?
>
> Many thanks ... ;)
> Markus
>
> -----Ursprüngliche Nachricht-----
> Von: maven-androi...@googlegroups.com
> [mailto:maven-androi...@googlegroups.com] Im Auftrag von Fredrik
> Jonson
> Gesendet: Montag, 15. Juni 2015 09:51
> An: 'Markus Wiesenbacher' via Maven Android Developers
> Betreff: Re: AW: [maven-android-developers] Trouble getting generated apk to
> run
>

Markus Wiesenbacher

unread,
Jun 18, 2015, 5:19:13 PM6/18/15
to maven-androi...@googlegroups.com

Why should ActiveMQ not work? It does meanwhile after a struggle ... 😁

My goal is to get a Message Broker work in Android!

Manfred Moser

unread,
Jun 19, 2015, 2:53:02 PM6/19/15
to maven-androi...@googlegroups.com
For any larger Java framework thats is more aimed at server side stuff the general assumption is that it doesnt work on Android unless the projects itself claims it does..

And for ActiveMQ I have not seen such a reference. If it works for you now, excellent.

Care to share?

manfred

'Markus Wiesenbacher' via Maven Android Developers wrote on 18.06.2015 14:19:

> Why should ActiveMQ not work? It does meanwhile after a struggle ...
>
> My goal is to get a Message Broker work in Android!
>
> Am 18.06.2015 22:57 schrieb "Manfred Moser" <man...@mosabuam.com <mailto:man...@mosabuam.com> >:
>> Why are you just trying with another framework that doesnt work on Android (ActiveMQ) ?
>>
>> What are you actually trying to do? What are you looking for?
>>
>> manfred
>>
>> 'Markus Wiesenbacher' via Maven Android Developers wrote on 18.06.2015 03:08:
>>
>> > Thanks for your quotes, I did make some advances:
>> >
>> > I moved from Kafka to ActiveMQ, and have a simple project which has a single
>> > broker-lib as dependency. This broker-lib has some transitive dependencies,
>> > which get all compiled into the dex/apk with you superb working
>> > android-maven-plugin. But:
>> >
>> > LogCat logs an exception, saying "Caused by: java.lang.NoClassDefFoundError:
>> > org.apache.activemq.command.ActiveMQTopic"
>> >
>> > This class is originally in a transitive dependency, and I checked that with
>> > dex2jar: It´s included in the dex!
>> >
>> > Do you have any hints why this class is not found? Do I miss a compile-option
>> > for the android-maven-plugin?
>> >
>> > Many thanks ... ;)
>> > Markus
>> >
>> > -----Ursprüngliche Nachricht-----
>> > Von: maven-androi...@googlegroups.com <mailto:maven-androi...@googlegroups.com>
>> > [mailto:maven-androi...@googlegroups.com <mailto:maven-androi...@googlegroups.com> ] Im Auftrag von Fredrik
>> > to maven-android-deve...@googlegroups.com <mailto:maven-android-developers%2Bunsu...@googlegroups.com> .
>> > For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout> .
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups
>> > "Maven Android Developers" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an email
>> > to maven-android-deve...@googlegroups.com <mailto:maven-android-developers%2Bunsu...@googlegroups.com> .
>> > For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout> .
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Maven Android Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-deve...@googlegroups.com <mailto:maven-android-developers%2Bunsu...@googlegroups.com> .
>> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout> .
>
> --
> You received this message because you are subscribed to the Google Groups "Maven Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-deve...@googlegroups.com <mailto:maven-android-deve...@googlegroups.com> .
> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout> .
Reply all
Reply to author
Forward
0 new messages