Problem with using as a project and as a jar.

615 views
Skip to first unread message

Ryuk

unread,
Aug 29, 2011, 6:56:59 PM8/29/11
to Android Compatibility Library for Google Maps - Support
Hi,

I've been wrestling with this for a number of hours now and keep
encountering the same problems.

If I try to use the compiled android-support-v4-r3-googlemaps.jar file
my test application compiles but does not execute on the platform .
The error I get when I look at logcat is as follows:

08-29 22:44:19.433: WARN/dalvikvm(326): Unable to resolve superclass
of Landroid/support/v4/app/FragmentActivity; (184)
08-29 22:44:19.433: WARN/dalvikvm(326): Link of class 'Landroid/
support/v4/app/FragmentActivity;' failed
08-29 22:44:19.433: WARN/dalvikvm(326): Unable to resolve superclass
of Lcom/company/hellofragment/HelloFragment; (52)
08-29 22:44:19.433: WARN/dalvikvm(326): Link of class 'Lcom/copany/
hellofragment/HelloFragment;' failed

08-29 22:44:19.546: ERROR/AndroidRuntime(326): FATAL EXCEPTION: main
08-29 22:44:19.546: ERROR/AndroidRuntime(326):
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.company.hellofragment/
com.company.hellofragment.HelloFragment}:
java.lang.ClassNotFoundException:
com.company.hellofragment.HelloFragment in loader
dalvik.system.PathClassLoader[/data/app/
com.company.hellofragment-1.apk]

The application this is cloned from WORKS with the android-support-
v4.jar that is distributed via the AVD. Additionally I checked to
ensure nothing from the previous app I used to base this on was
lurking around so as to cause the dalvikvm errors. It would suggest
that android-support-v4.jar and android-support-v4-r3-googlemaps.jar
are conflicting but I cannot be sure about this.

I then attempted to then build the project in eclipse and try to use
it directly , first by using the project directly , secondly by
importing it from the ant build.xml. I could not successfully get this
to compile without errors pertaining to FragmentTransaction.detach(),
FragmentTransaction.attach(), Fragment.isDetached() . I saw that this
was answered previously with an issue between r2 and r3 but as far as
I am aware I am using the latest versions of everything and nothing is
out of date. I just can't get it to build for the life of me. I cannot
build the .jar myself successfully nor can I find any steps that
explain what I need to do this correctly so it's a little bit "voodoo
magic" for me as to how you've achieved that. Although I'm not sure if
it would help my initial fault I can't build it to see if it would
( nor can I use it as a base to build the source from the AVD supplied
package ).

I'm using Eclipse 3.70 and I've pulled the required libraries from
AVD. My target android VM is 2.2 ( api level 8 ) and my initial
fragment test application works fine on that VM ( as well as api 11 &
api 13 ). However as soon as I swap to using the map enabled .jar i
get the first error described above. The

At this stage I can't get the .jar or the project to work. Any help
you can through my way would be greatly appreciated as I desperately
need to use this mechanism to achieve the solution I require.

Thanks for taking the time to read all that , really hope you can
help.

Pete Doyle

unread,
Aug 29, 2011, 8:55:11 PM8/29/11
to android-support-v4...@googlegroups.com
Thanks for the message.  See responses inline below...

Are you by any chance using Proguard?  If so, make sure to add the following to your proguard.cfg:
  -keep class android.support.v4.app.** { *; }
  -keep interface android.support.v4.app.** { *; }

Also, add "!code/allocation/variable" to the "-optimizations" line (if you have one).


It would suggest that android-support-v4.jar and android-support-v4-r3-googlemaps.jar are conflicting but I cannot be sure about this.

android-support-v4-r3-googlemaps.jar is meant to replace android-support-v4.jar.  Make sure only one is in the build path of your project (or neither if you add the library project to your project's build path).  I recommend using the jar.  There's not much reason to use it as a library project unless you have some customizations / bug fixes you want to make to the original compatibility library source. 


I then attempted  to then build the project in eclipse and try to use
it directly , first by using the project directly , secondly by
importing it from the ant build.xml. I could not successfully get this
to compile without errors pertaining to FragmentTransaction.detach(),
FragmentTransaction.attach(), Fragment.isDetached() . I saw that this
was answered previously with an issue between r2 and r3 but as far as
I am aware I am using the latest versions of everything and nothing is
out of date. I just can't get it to build for the life of me.

It turns out I completely forgot to update the Eclipse project's build path for the r3 release (the ACL r3 release added a bunch of new source folders).  I just pushed a fix:

If you "git pull" you should have it locally.

Specifically with regard to FragmentTransaction.attach(), FragmentTransaction.detach() and Fragment.isDetached(), I'm not 100% sure what the issue is.  I know they were added in API level 13 *and* r3 of the ACL.  The thing is r3 of the ACL has those methods without requiring API level 13.

Can you double-check to make sure all your imports use the compatibility library (i.e. imports of Fragment, FragmentActivity, etc use the android.support.v4 packages)?

 
I cannot build the .jar myself successfully nor can I find any steps that
explain what I need to do this correctly so it's a little bit "voodoo
magic" for me as to how you've achieved that. Although I'm not sure if
it would help my initial fault I can't build it to see if it would
( nor can I use it as a base to build the source from the AVD supplied
package ).
Its easiest to do it from the command line (and required Ant 1.8.1 or higher):
  
    cd android-support-v4-googlemaps
    ant clean-build

That'll build the jar and put it in the build/jar directory.

 
I'm using Eclipse 3.70 and I've pulled the required libraries from
AVD. My target android VM is 2.2 ( api level 8 ) and my initial
fragment test application works fine on that VM ( as well as api 11 &
api 13 ). However as soon as I swap to using the map enabled .jar i
get the first error described above. The
Definitely make sure you only have android-support-v4-r3-googlemaps.jar in your build path (and not android-support-v4.jar).  Also, make sure not to put any android.jar or maps.jar in your build path.  Instead let the ADK add them for you by setting the API level (since you're using API Level 8, use "Google APIs" level 8).

 
At this stage I can't get the .jar or the project to work. Any help
you can through my way would be greatly appreciated as I desperately
need to use this mechanism to achieve the solution I require.

Thanks for taking the time  to read all that , really hope you can
help.
I really hope something above helps.  Its hard to say without seeing your setup.  Let me know if any of it helps and I'll add some updated instructions to the README to help others out in the future.  Or if it doesn't. :-)

Thanks,
Pete Doyle

Ryuk

unread,
Aug 30, 2011, 6:55:47 AM8/30/11
to Android Compatibility Library for Google Maps - Support
Hi Pete,

Thanks for your super fast reply!

I made the proguard changes you suggested BUT it didn't seem to make a
difference.
I went back through the code with a fine tooth comb to find a really
STUPID mistake in AndroidManifest.xml
I'd got <uses-library android:name="com.google.android.maps" />
defined OUTSIDE of the application node
and <uses-permission android:name="android.permission.INTERNET" />
was spelt incorrectly!!!

I made the changes and guess what, IT RAN. The problem was between the
chair and the keyboard. Just needed
a break from the screen I guess. Thanks for the help.

Also your projected is marked to expire on the 31st? Is that the
case?
>  I just pushed a fix:https://github.com/petedoyle/android-support-v4-googlemaps/commit/0bc...

Pete Doyle

unread,
Aug 31, 2011, 3:28:16 AM8/31/11
to android-support-v4...@googlegroups.com
Awesome, I'm glad its working!


I made the proguard changes you suggested BUT it didn't seem to make a
difference.
I went back through the code with a fine tooth comb to find a really
STUPID mistake in AndroidManifest.xml
I'd got         <uses-library android:name="com.google.android.maps" />
defined OUTSIDE of the application node
and     <uses-permission android:name="android.permission.INTERNET" />
was spelt incorrectly!!!
 
Darn, a missing/misspelled <uses-library ...>  always gets me too.  Android's error message always throws me off (ClassNotFoundException on the class _extending_ MapActivity instead of saying MapActivity is missing).

 
Also your projected is marked to expire on the 31st? Is that the case?

Where do you see that?  I'm not aware of anything expiring the 31st.  Definitely not the github project.

Thanks,
Pete
Reply all
Reply to author
Forward
0 new messages