Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sdk to version 25 and fix ResourceClassGenerator to not write final fields #757

Merged
merged 15 commits into from
Mar 22, 2017

Conversation

hameno
Copy link
Contributor

@hameno hameno commented Jan 12, 2017

No description provided.

pom.xml Outdated
<android.builder.version>1.5.0</android.builder.version>
<android.tools.version>24.5.0</android.tools.version>
<android.builder.version>2.2.3</android.builder.version>
<android.tools.version>25.2.0</android.tools.version>
Copy link
Member

@Shusshu Shusshu Jan 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

25.2.3 and if we have too many problems we can try the latest beta.

Sorry this is only on jcenter.....

Copy link
Contributor Author

@hameno hameno Jan 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this is only on jcenter.....

Argh, hate what has happened to the maven ecosystem lately...

pom.xml Outdated
<android.builder.version>1.5.0</android.builder.version>
<android.tools.version>24.5.0</android.tools.version>
<android.builder.version>2.2.3</android.builder.version>
<android.tools.version>25.2.3</android.tools.version>
</properties>

Copy link
Member

@Shusshu Shusshu Jan 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need this too:

  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>bintray-maven</id>
      <name>bintray</name>
      <url>https://dl.bintray.com/android/android-tools</url>
    </repository>
  </repositories>

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017

I'm updating stuff on my branch https://github.com/simpligility/android-maven-plugin/tree/update-sdk-25

You can merge stuff from it to your PR. I will most probably not finish this upgrade as I once tried before and didn't get some stuff.
But this time I'll keep the work in progress in a branch

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017

Now I remember, last time I couldn't find how to fix that change but you did it :)

final String packageName = VariantConfiguration.getManifestPackage( libManifestFile );
-> final String packageName = new DefaultManifestParser( libManifestFile ).getPackage();

@hameno
Copy link
Contributor Author

hameno commented Jan 12, 2017

Yeah, I found that code in the old version, VariantConfiguration.getManifestPackage basically just called the DefaultManifestParser...

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017

So in my branch only the emulator test is not working... and the manifest merger 2 needs to be checked
and ofc your final field stuff...

You can merge my stuff in your PR if you want.

UPDATE:

Btw some code is gone from the latest beta ...

import com.android.builder.internal.SymbolLoader;
import com.android.builder.internal.SymbolWriter; 

I guess it would be better to target the latest beta

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017

I've updated my branch with the latest BETA stuff

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017

SymbolWiter is deprecated https://android.googlesource.com/platform/tools/base/+/master/sdklib/src/main/java/com/android/sdklib/internal/build/SymbolWriter.java

They say to use AndroidBuilder https://android.googlesource.com/platform/tools/build/+/master/builder/src/main/java/com/android/builder/AndroidBuilder.java

And then I found

package com.android.builder.symbols;

import com.android.builder.symbols.SymbolIo;
import com.android.builder.symbols.SymbolTable;
import com.android.utils.Pair;
import com.google.common.base.Preconditions;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.function.Consumer;
public class RGeneration {
    private RGeneration() {
    }

    public static void generateRForLibraries(SymbolTable main, Collection<SymbolTable> libraries, File out, boolean finalIds) {
        Preconditions.checkArgument(out.isDirectory(), "!out.iDirectory");
        Pair mainP = Pair.of(main.getTablePackage(), main.getTableName());
        HashMap toWrite = new HashMap();
        Iterator var6 = libraries.iterator();

        while(var6.hasNext()) {
            SymbolTable k = (SymbolTable)var6.next();
            Pair st = Pair.of(k.getTablePackage(), k.getTableName());
            if(!st.equals(mainP)) {
                SymbolTable existing = (SymbolTable)toWrite.get(st);
                if(existing != null) {
                    toWrite.put(st, existing.merge(k));
                } else {
                    toWrite.put(st, k);
                }
            }
        }

        var6 = (new HashSet(toWrite.keySet())).iterator();

        while(var6.hasNext()) {
            Pair k1 = (Pair)var6.next();
            SymbolTable st1 = (SymbolTable)toWrite.get(k1);
            st1 = main.filter(st1).rename(st1.getTablePackage(), st1.getTableName());
            toWrite.put(k1, st1);
        }

        toWrite.values().forEach((st) -> {
            SymbolIo.exportToJava(st, out, finalIds);
        });
    }
}

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017

I will let you finish this PR and properly test it :p

@hameno
Copy link
Contributor Author

hameno commented Jan 12, 2017

I'll try, any hint on my previous question ("I'm not sure how I can detect if the generation is run during test lifecycle (and inside an aar library).")?

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017

Maybe @mosabua knows

@hameno
Copy link
Contributor Author

hameno commented Jan 12, 2017

I've made some progress updating it to match AndroidBuilder#processResources, currently testing

@hameno
Copy link
Contributor Author

hameno commented Jan 12, 2017

Is there a IntelliJ codestyle config anywhere? Checkstyle kills me here...

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017

haha I also hate the codestyle :p @mosabua Do we have an intellij formatter?

@hameno
Copy link
Contributor Author

hameno commented Jan 12, 2017

Huh, so now it only generates the main R file (but includes all symbols from libs), not yet sure how to fix that using the new classes.

@hameno
Copy link
Contributor Author

hameno commented Jan 12, 2017

I think that's it, my (rather complex 20-modules) project is now building successfully and all tests are working, even with robolectric 3.2.1.
Now I need to verify, if all (manifests etc) is correct :)

Also: I still need to check an actual apk build (my project only consists of aar libraries). I think there is still one bug: no final (which is required for apks)

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017 via email

@hameno
Copy link
Contributor Author

hameno commented Jan 12, 2017

Yes, it's used heavily in this project. It's on my to-do list for apk build test. Gonna compare old and new APK using Android studio.

@Shusshu
Copy link
Member

Shusshu commented Jan 12, 2017 via email

@hameno
Copy link
Contributor Author

hameno commented Jan 12, 2017

APK looks good, will cleanup this branch and try to match the codestyle and then it should be done

@hameno
Copy link
Contributor Author

hameno commented Feb 11, 2017

@Shusshu Done

@william-ferguson-au
Copy link
Contributor

I have never used the emulator mojo either.
Would love to get some metrics over which mojos are used and how much.

@Shusshu
Copy link
Member

Shusshu commented Feb 25, 2017

@hameno you can use rc1 now

<android.builder.version>2.3.0-rc1</android.builder.version>
<android.tools.version>25.3.0-rc1</android.tools.version>

@Shusshu
Copy link
Member

Shusshu commented Mar 3, 2017

You can update it again ;) it's released 2.3.0 and then somebody should test & merge this

@hameno hameno force-pushed the final_ids branch 4 times, most recently from f572a33 to 3ebe946 Compare March 18, 2017 08:27
@hameno
Copy link
Contributor Author

hameno commented Mar 18, 2017

I got every test except AbstractEmulatorMojoTest to pass.

AbstractEmulatorMojoTest fails due to an ExceptionInInitializerError because AndroidSdkHandler cannot init the SchemaModule fields (ADDON_MODULE, REPOSITORY_MODULE, SYS_IMG_MODULE, COMMON_MODULE). I tracked it down to SchemaModule:156 which tries to get a namespace for a XML annotation. I'm not sure why this fails as the LinkedList contains the annotation but with a different hash?! Maybe PowerMock is the reason? Should we just disable the test?

@Shusshu
Copy link
Member

Shusshu commented Mar 18, 2017

I don't mind if we disable it... wdyt @simpligility/android-maven-plugins-core-committers ?

@mosabua
Copy link
Member

mosabua commented Mar 18, 2017

If we disable support for the emulator mojos we completely loose the ability to run automated integration tests. That sucks imho. I am however not aware of the plans from the SDK team on how to support emulator interaction going forward (or even the current status).

@mosabua
Copy link
Member

mosabua commented Mar 18, 2017

But yes.. maybe we can disable the test for now or at least the failing method and try to replace it. That whole mocking is a PITA anyway. If the mojo works in an integration test maybe that test can completely disappear and we dont worry about it.

@Shusshu
Copy link
Member

Shusshu commented Mar 22, 2017

@hameno can you add a @ignore for the emulator test?

@simpligility/android-maven-plugins-core-committers I have been testing the emulator-start command and it actually doesn't work even in previous versions

The script it creates can be executed manually but the CommandExecutor cannot run it. I couldn't find why.

So let's merge this in with @ignore on the emulator test

@hameno
Copy link
Contributor Author

hameno commented Mar 22, 2017

Okay, gonna do this later today.

@Shusshu Maybe the script does not have execute permissions?

@Shusshu
Copy link
Member

Shusshu commented Mar 22, 2017

I was able to run it via the cmd line

@mosabua
Copy link
Member

mosabua commented Mar 22, 2017

It sucks that the plugin needs the bintray repo. That basically means it wont work out of the box for normal Maven users and we need to update the docs. But I think we should merge this now and iterate in master..

@Shusshu
Copy link
Member

Shusshu commented Mar 22, 2017 via email

@mosabua
Copy link
Member

mosabua commented Mar 22, 2017

Great ... you wanna merge this now then?

@mosabua
Copy link
Member

mosabua commented Mar 22, 2017

I am working atm but hopefully can give this a whirl tonight.. just got back last night..

@Shusshu
Copy link
Member

Shusshu commented Mar 22, 2017 via email

@mosabua
Copy link
Member

mosabua commented Mar 22, 2017

Sounds good. Will probably do a release associated to that .. have you tried the site build? With the change to JDK 8 it probably fails all over the place..

@Shusshu
Copy link
Member

Shusshu commented Mar 22, 2017 via email

@hameno
Copy link
Contributor Author

hameno commented Mar 22, 2017

I've disabled the test

@mosabua mosabua merged commit e906101 into simpligility:master Mar 22, 2017
@hameno hameno deleted the final_ids branch March 22, 2017 17:30
@mosabua
Copy link
Member

mosabua commented Mar 22, 2017

Btw I updated the changedlog and remove the bintray repo. All good so far.. more tonight. Will up version to 4.5.0 for release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants