Re: Moving app from ADT 20 to ADT 21 causes java.lang.NoSuchFieldError

147 views
Skip to first unread message

Adam Vollmer

unread,
Dec 6, 2012, 11:18:33 AM12/6/12
to adt...@googlegroups.com
This may be related to my problem, where a library resource depends on a library resource, and ends up with the resource moving which R file it belongs to in the application. The solution for me was to rename all of the affected library project package names to the application package name, but that may not be suitable for you.


On Thu, Dec 6, 2012 at 7:36 AM, Henrique Sousa <henrique.so...@gmail.com> wrote:
Good morning everyone,

While performing a installation of the ADT bundle (Eclipse ADT + SDK) on a new machine, I found out that my project started crashing with java.lang.NoSuchFieldError exception on a R resource.

On my previous machine with Motodev 4.1 + ADT 20, everything works just perfect. I cannot, for the love of God, figure out out the solve the issue, and due to IP I cannot paste here much code and logs:

12-06 12:02:09.590: E/ACRA(5785): ****APPNAME**** fatal error : com.other.package.R$string.srv_geo_areas_short_get
12-06 12:02:09.590: E/ACRA(5785): java.lang.NoSuchFieldError: com.other.package.R$string.srv_geo_areas_short_get

If I compile and run the apk generated with ADT 20, everything works just fine.

I thank you in advance for any help/pointers in solving this issue.
Thanks again.

Best regards,
Henrique Sousa

Xavier Ducrohet

unread,
Dec 6, 2012, 1:03:54 PM12/6/12
to adt...@googlegroups.com
As Adam indicates in his reply, this may be due to shared package name
in different libraries.
We have a 21.0.1 going to through final testing that will fix this
issue (by supporting it when it can, and stopping the build when it
cannot).

In the mean time, check your library package names and change them if
this applies to you. If not we'll have to investigate further.

On Thu, Dec 6, 2012 at 4:36 AM, Henrique Sousa
<henrique.so...@gmail.com> wrote:
> Good morning everyone,
>
> While performing a installation of the ADT bundle (Eclipse ADT + SDK) on a
> new machine, I found out that my project started crashing with
> java.lang.NoSuchFieldError exception on a R resource.
>
> On my previous machine with Motodev 4.1 + ADT 20, everything works just
> perfect. I cannot, for the love of God, figure out out the solve the issue,
> and due to IP I cannot paste here much code and logs:
>
> 12-06 12:02:09.590: E/ACRA(5785): ****APPNAME**** fatal error :
> com.other.package.R$string.srv_geo_areas_short_get
> 12-06 12:02:09.590: E/ACRA(5785): java.lang.NoSuchFieldError:
> com.other.package.R$string.srv_geo_areas_short_get
>
> If I compile and run the apk generated with ADT 20, everything works just
> fine.
>
> I thank you in advance for any help/pointers in solving this issue.
> Thanks again.
>
> Best regards,
> Henrique Sousa



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Henrique Sousa

unread,
Dec 7, 2012, 8:14:48 AM12/7/12
to adt...@googlegroups.com
Turned out you were right, we had two libraries with the same package name in both of them.

However I renamed both packages to distinct names and cleaned all projects, but the problem remained.

We'll wait for a fix then. If you need more info, I'll gladly help in any way you'll need. I've attached a picture of the offending R.string.

Thanks again for your effort.
My best regards,
Henrique Sousa
adt21.png

Harshad RJ

unread,
Dec 29, 2012, 2:11:28 PM12/29/12
to adt...@googlegroups.com
This is affecting me as well. And I don't have common package names between library and app.

I have a library project in which I store common resources, and my apps depend on this library project to provide resources. This used to work fine until ADT 21, but now, because of the optimisation of R class I think, the app builds fail.

Is there a way to prevent ADT from optimising fields in the R class?
Reply all
Reply to author
Forward
0 new messages