Kategorien
Android

Android Gradle Plugin 2.2.0-alpha3 is missing zipalign

I have setup a Jenkins that automatically uploads nightly APKs to the Play Store. Starting some days ago, the upload to the Play always failed with this: Upload failed: APK is not zip aligned.

So I investigated a bit found that one of the changes that I did the days these issues started was to update the Gradle plugin to 2.2.0-alpha3. Doing a quick Google search showed that everybody is having this issue.

Gradle plugin 2.2.0-alpha3 is somehow missing the zipalign task and will create APKs that are NOT zip aligned! I also tested to manually sign the APK afterwards, which also fails…

So for now, the only solution would be to revert back to 2.2.0-alpha2 of the Gradle plugin. Which also forces you to revert back to Android Studio 2.2 Preview 2 since Preview 3 will not compile your project when you don’t use plugin version 2.2.0-alpha3… But how do we do that?

Yeah, you have to do a fresh installation of Android Studio 2.2 Preview 2 and perform the updates until you are at Preview 2 and then stop, don’t install the Preview 3 update and wait for Preview 4.

[1] https://code.google.com/p/android/issues/detail?id=212591
[
2] http://tools.android.com/download/studio/builds/2-2-preview-2

Kategorien
Android

Configuration for Gitlab CI Android projects

Hey everyone,

I just recently wanted to give Gitlab CI a try. It is the CI part of the Gitlab hosting solution. They just recently announced that you can use their shared runners that they are now running on DigitalOcean’s servers for free!

So I currently have an Android project that I want to have built on one their free shared runners. I wasn’t able to find a straight forward solution for a .gitlab-ci.yml  file that works for Android projects.

So, this is what I now successfully use for building my Android project on Gitlab CI’s free shared runners:

image: java:openjdk-8-jdk

before_script:
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
  - tar --extract --gzip --file=android-sdk.tgz
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-23
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-23.0.2
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository
  - export ANDROID_HOME=$PWD/android-sdk-linux
  - chmod u+x ./gradlew

build:
  script:
    - ./gradlew assemble lint
  artifacts:
    paths:
    - app/build/outputs/

Let’s analyse it:

At first we have image: java:openjdk-8-jdk . This instructs Gitlab CI to load a Docker image with OpenJDK 8 configured. This is because I make use of RetroLambda -> we need Java 8.

Next we update the system via apt-get and install some dependecies.

Next we download and unzip the current Android SDK.

Once unzipped, we can use the Android SDK Manager to install all of our needed Android SDK components.

Next we need to set the ANDROID_HOME environment variable.

Finally, we need to make the Gradle Wrapper script executable.

Then in the script: block, we define the actual command that will be executed. Here we can also add tests etc (you know the Gradle commands available…)

And that’s it. Now, whenever you push new commits to your repository, Gitlab will automatically perform a build on Gitlab CI’s free shared runners hosted on DigitalOcean.

After a successful build, we set the archives/files that we want to save for later download. Which, in this case, are just all file in the build/outputs/ folder. That includes Lint results, APKs, etc…

 

I hope this helps a lot of Android devs to setup their Android projects with Gitlab-CI

Kategorien
Android

TextView – getTextSize() vs setTextSize()

komedi_1419026753657_984

I decided to resume publishing some of the Android related issues that I stumble upon and workarounds and fixes for these issues.

So today I need to reduce the text size of the TextView in code at runtime. Easy peasy, I thought.

textView.setTextSize(textView.getTextSize-1);

Well, it didn’t work. Instead, the text size was now much much bigger then it was before. What? Bigger? Yes! But why?

That confusing thing behind this is that you have to realize that the two function have different measurement units as parameters and return values.

TextView.getTextSize()  returns the size in pixels and TextView.setTextSize(…)  expects the value to be in „scale independent pixels (SP)“.

So what I ended up doing is:

float oneSp = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 1, getResources().getDisplayMetrics());
textView.setTextSize((textView.getTextSize()/oneSp) - 1);

Another approach would be to use the second function to set the text size which also accepts the unit, which would be TypedValue.COMPLEX_UNIT_PX  in this case:

textView.setTextSize(TypedValue.COMPLEX_TYPE_PX, textView.getTextSize() - 1);

 

Kategorien
M101

M101 – The Pinwheel Galaxy

Got at least some minutes of clear sky tonight, after having no clear sky at all for multiple weeks 🙂

This is 30x60s at ISO1600.

M101

Kategorien
NGC6960

NGC6960 – The Veil Nebula – First Sight

First try on a non-Messier object. Went pretty good I think 🙂

This is just a quick exposure of 12x120s at ISO1600.

NGC6992

Kategorien
M31

M31 – Andromeda

First try with the new telescope. This is just a short exposure of 10x120s at ISO1600.

M31

Kategorien
M45

M45 – First image with new telescope

This is the first quick image (11x120s at ISO1600) of M45 with the new telescope. The difference is crazy! 🙂

M45

Kategorien
M27

M27 – The Dumbbell Nebula – Second Try

My second try on the Dumbbell Nebula. This is 16x120s at ISo1600.

M27 - The Dumbbell Nebula M27 - The Dumbbell Nebula

Kategorien
M16

M16 – The Eagle Nebula- Second Try

My second try on the Eagle Nebule, this time with 33×120 second exposures at ISO1600.

I especially love the „Pillars of Creation“ 🙂

M16 - The Eagle Nebula

Kategorien
M75

M75 – First Sight

I used this night to continue my journey through the Messier catalog.

This is M75, 14x30s at ISO1600.

M75