kingdom578 / maven-android-plugin

Automatically exported from code.google.com/p/maven-android-plugin
0 stars 0 forks source link

wrong identifiers in R file in apklib module #441

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. application that have 2+ modules:
   - library module (
          packaging: apklib
          package: com.library
          drawables: lib_launcher.png, idea.png
   - application module
          packaging: apk
          package: com.application
          depends on apklib
          drawables: ic_launcher.png
2. in a application try to use com.library.R to get some drawable with name: 
idea.png

What is the expected output?
idea.png on a screen

What do you see instead?
incorrect .png file (for ex: ic_launcher.png)
you can see and reproduce it in attached project

What version of maven-android-plugin are you using?
3.8.2 (at 3.8.1 no such problem appears)

What are the complete output lines of "mvn -version" on your machine?
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 
18:22:22+0300)
Maven home: /opt/apache-maven-3.1.1
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-i386/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.11.0-15-generic", arch: "i386", family: "unix"

Please provide any additional information below.
This is a common problem for projects that have "apklib" modules and can be 
easily reproduced!

problem is that R file for apklib modules has incorrect values
please, see attached example on which a problem can be easily reproduced

Attached application guide:
In module "application" -> com.example.application.ExampleActivity.java ->
lines 22-24 sends log messages that contains values: 
"com.example.library.R.drawable.idea"
"com.example.application.R.drawable.idea"
and they are different!

Original issue reported on code.google.com by olegalex...@gmail.com on 16 Jan 2014 at 8:52

Attachments:

GoogleCodeExporter commented 9 years ago
I can confirm this problem with apklib.
I mentioned it in the wrong ticket (437)

Original comment by benoit.b...@gmail.com on 19 Jan 2014 at 10:36

GoogleCodeExporter commented 9 years ago
I am also having this problem. I couldn't upgrade to 3.8.2

Original comment by maca...@gmail.com on 20 Jan 2014 at 9:28

GoogleCodeExporter commented 9 years ago
It's very actual for me.  I have same problem. Can you help us?

Original comment by Shumyl...@gmail.com on 24 Jan 2014 at 10:05

GoogleCodeExporter commented 9 years ago
Working on a big project with a complex structure that consist of multiple 
apklibs. Having problem with amount of fields over 65536 because of problem in 
3.8.1 version.
So I need to use 3.8.2 version, but I met current issue and can't use maven at 
all for project build.

Original comment by ann.isil...@gmail.com on 25 Jan 2014 at 2:06

GoogleCodeExporter commented 9 years ago
I compared this to output from a 3.6.0 build where both R$id.smali matched. 
Using the original posters example, the com.example.application.R has the 
correct values and com.example.library.R has the incorrect values.

Original comment by mala...@playhaven.com on 5 Feb 2014 at 4:23

GoogleCodeExporter commented 9 years ago
Point me to a project/branch exhibiting this behaviour?

Original comment by william....@xandar.com.au on 10 Feb 2014 at 10:32

GoogleCodeExporter commented 9 years ago
Scratch that, I see you've attached a project.

Original comment by william....@xandar.com.au on 10 Feb 2014 at 11:22

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I just tested it against the current master 3.8.3-SNAPSHOT of this day and it 
still does not work but that's expected as nothing was done in order to fix it 
;) 

Original comment by benoit.b...@gmail.com on 11 Feb 2014 at 10:58

GoogleCodeExporter commented 9 years ago
OK, after fixing the errors in this project up I can't find any meaningful 
differences between the output for 3.8.1, 3.8.2 and 3.8.3-SNAPSHOT.

I've attached my modified project.

I don't see any problem here at all.

The core problem is that the parent project declares a plugin management config 
for android-maven-plugin (which is ok), but then declares a a plugin config for 
maven-android-plugin which is the old plugin.

This was obvious from the build output because there are warnings for not 
version info for maven-android-plugin, so it defaulted to the last version 
which was 3.0.0-alpha

The other thing obfuscating the output was that one of the images had been set 
as a background as well as one of the foreground images. So it was nigh well 
impossible to tell whether anything was wrong.

Please try and create simple projects that readily highlight the issue.

Manfred, this issue should be closed as not an issue.

Original comment by william....@xandar.com.au on 17 Feb 2014 at 11:02

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I should have mentioned than when I fixed up the pom I was able to reproduce 
the problem.
But I agree this sample project wasn't properly set.

Original comment by benoit.b...@gmail.com on 17 Feb 2014 at 11:42

GoogleCodeExporter commented 9 years ago
One thing that's not normal for me is if you look at 
maven-android-plugin-issue-441\application\target\generated-sources\r\com\exampl
e\library\R.java
You have:
public static int idea=0x7f020000;
public static int lib_launcher=0x7f020001;

& in the other R file
maven-android-plugin-issue-441\application\target\generated-sources\r\com\exampl
e\application\R.java

You have:
public static final int idea=0x7f020001;
public static final int lib_launcher=0x7f020002;

Original comment by benoit.b...@gmail.com on 17 Feb 2014 at 12:31

GoogleCodeExporter commented 9 years ago
Need to be clear about "reproduce the problem". I see 3 images being displayed, 
two of which are identical, because their source images are identical and one 
which is different. It looks exactly as expected to me.

I believe the R values showing in generated-sources are furphies. 
The values n R.txt are:

int drawable ic_launcher 0x7f020000
int drawable idea 0x7f020001
int drawable lib_launcher 0x7f020002
int id start_library 0x7f050000
int layout library_main 0x7f030000
int layout main 0x7f030001
int string app_name 0x7f040000

which is what are being used.

Original comment by william....@xandar.com.au on 17 Feb 2014 at 12:47

GoogleCodeExporter commented 9 years ago
Look at the background of the first textview
it is supposed to be the idea icon and not the launcher

Original comment by benoit.b...@gmail.com on 17 Feb 2014 at 12:52

Attachments:

GoogleCodeExporter commented 9 years ago
so this problem only occurs when we use a Lib which is using its res drawables 

Original comment by benoit.b...@gmail.com on 17 Feb 2014 at 12:54

GoogleCodeExporter commented 9 years ago
this problem not only with drawables. The problem is that all identifiers in R 
file of apklib is incorrect. 
So we can easily got an NullPointerException when inflating wrong layout and 
trying to get some View (for example)

Original comment by olegalex...@gmail.com on 17 Feb 2014 at 1:02

GoogleCodeExporter commented 9 years ago
i think this issue appears as a side effect of fixing another issue:
"too many fields in R file" - when R file of every apklib contained links to 
each resource from the whole project.

Original comment by olegalex...@gmail.com on 17 Feb 2014 at 1:08

GoogleCodeExporter commented 9 years ago
It's not a side effect of that issue. it's a side effect of supporting aar.

R strings ids are perfectly fine so it fails on other id's

Original comment by benoit.b...@gmail.com on 17 Feb 2014 at 1:10

GoogleCodeExporter commented 9 years ago
There is no difference between String resources and other resources. I think  
it is just probability that has meant we haven't seen this on String resources 
yet.

Original comment by william....@xandar.com.au on 17 Feb 2014 at 1:15

GoogleCodeExporter commented 9 years ago
Let's do some more research. Now that we have a project that fails we can 
actually investigate.

Original comment by william....@xandar.com.au on 17 Feb 2014 at 1:16

GoogleCodeExporter commented 9 years ago
As far as the IDs, I can also tell you that it broke since 3.6.0 - not sure
if that helps at all.

Original comment by mala...@playhaven.com on 17 Feb 2014 at 1:36

GoogleCodeExporter commented 9 years ago
please, refer to GeneratedSourcesMojo -> generateApkLibRs() method.
It generates R files for apklibs only based on apklib resources(+ their 
dependencies).

But Apk project has lot more resources (apklib resources + its own resources), 
so R file has lot more identifiers.

As a result we have id mismatch in R.class from apklib and R.class from apk.

Original comment by olegalex...@gmail.com on 17 Feb 2014 at 1:42

GoogleCodeExporter commented 9 years ago
>> As far as the IDs, I can also tell you that it broke since 3.6.0 - not sure
if that helps at all.

No, this issue appears at 3.8.2 (at 3.8.1 no such problem appears(including 
3.6.0))
Maybe you have met another issue at 3.6.0

Original comment by olegalex...@gmail.com on 17 Feb 2014 at 1:52

GoogleCodeExporter commented 9 years ago
No, I meant 3.6.0 didn't have this problem.

Original comment by mala...@playhaven.com on 17 Feb 2014 at 2:21

GoogleCodeExporter commented 9 years ago
I have found possible solution, will make pull-request soon.

Original comment by olegalex...@gmail.com on 17 Feb 2014 at 8:05

GoogleCodeExporter commented 9 years ago
Sample app that shows the problem.
-Ptest to run tests that shows the error (works without -PFAIL)
-PFAIL to use 3.8.2
-PSTILL_FAILING to use 3.8.3-SNAPSHOT

https://github.com/tobias-/maven-multilib-sample-app

Tests could probably be converted to normal unit tests (instead of 
instrumentation), but this I made a boiler plate app instead so that it didn't 
just end up a one-shot test case.

Original comment by tob...@olsson.be on 17 Feb 2014 at 8:24

GoogleCodeExporter commented 9 years ago
made a pull-request, waiting for review

Original comment by olegalex...@gmail.com on 17 Feb 2014 at 9:04

GoogleCodeExporter commented 9 years ago
Issue 443 has been merged into this issue.

Original comment by william....@xandar.com.au on 17 Feb 2014 at 10:18

GoogleCodeExporter commented 9 years ago
fixed in 3.8.3-SNAPSHOT

Original comment by benoit.b...@gmail.com on 18 Feb 2014 at 6:25

GoogleCodeExporter commented 9 years ago
Confirmed.  I used apktool to verify that my IDs now match.  =)

Original comment by mala...@playhaven.com on 18 Feb 2014 at 6:58

GoogleCodeExporter commented 9 years ago
Sorry for the "me too", but I just wanted to confirm that my test case works 
too. Current 3.8.3-SNAPSHOT fixes this issue.

Original comment by tob...@olsson.be on 18 Feb 2014 at 9:12

GoogleCodeExporter commented 9 years ago
Fixed in 3.8.3 snapshot .. will go out with 3.8.3 soon

Original comment by mosa...@gmail.com on 21 Feb 2014 at 9:40

GoogleCodeExporter commented 9 years ago
Sorry, but when this version 3.8.3 will be available? Have the same problem in 
2 projects.

Original comment by Geleznod...@gmail.com on 16 May 2014 at 9:11

GoogleCodeExporter commented 9 years ago
3.9.0-rc.1 has already been released. It should have been fixed in that. So you 
can give it a go.

We are preparing for 3.9.0-rc.2 which fixes some other issues. But that may be 
weeks away.

Original comment by william....@xandar.com.au on 16 May 2014 at 9:25