Background: I have been using the Terminal-IDE program to learn about doing Android development (I like vim, for starters...).
https://play.google.com/store/apps/details?id=com.spartacusrex.spartacuside
As shipped, it supports SDK level 9. I want to support level 14 (Android 4.0+), so that I can use GridLayout instead of the more complex TableLayout.
I emailed the author, who responded in less than a day (kudos!), but, when I look for a replacement android.jar under /system on my tablet (Nexus 7 model 2), that particular jar does not exist, only many other jars with longer names that are just wrappers around dex files.
Anybody ran into this problem and solved it?
Upon further emails with the author of the environment, I found an easy solution:
Go to the system/classes directory of the T-IDE install
Rename the existing jar (e.g. - android.jar.t-ide)
Copy the android.jar from the SDK (or sdk directory within Android Studio) with an alternate name (e.g. - android.jar.studio.sdk)
Make a symbolic link from the updated SDK jar to android.jar
Now I can use GridLayout from Android 4.0 - compiles (on the tablet) and runs just fine. I did not need to update any other environment variables or configurations, as I replaced the original android.jar with a sym-link to the updated jar (and an "ls -l" will show which one is being used as "android.jar").
Note: if you get the updated android.jar from Android Studio, be sure to get the one in the sdk directory, not the one in the "plugins" directory, which won't work.
Related
My Android app includes a set of executables that are extracted to app directory (/data/data/%package%/) on the first run. It worked just fine if targeted to Android 28 (targetSdkVersion). Since November 2, 2020 it not allowed in Google Play and all the apps must target to 29. So it stopped working with permission exception.
What directory should executables be put to now?
PS. Some similar apps have the same issue.
https://developer.android.com/about/versions/10/behavior-changes-10#execute-permission
When targeting API 29 (Android 10 / Q) or above, it is not possible anymore to have execute permission for files stored within the app's home directory (data), which is exactly what you are describing (/data/data/%package%/).
This Android 10 modification was introduced in commit: https://android-review.googlesource.com/c/platform/system/sepolicy/+/804149 and was then confirmed officially by Google here: https://issuetracker.google.com/issues/128554619
This significant change is being discussed by various projects, in termux/termux-app#1072 for instance. One recommended and (hopefully) future-proof way is to extract program binaries into the application's native lib directory (with android:extractNativeLibs=true), where files can still be executed but are stored read-only for improved security.
Here are examples showing how to handle this change, in Termux with commit f6c3b6f in the android-10 branch or in this other project showing how to run the Erlang runtime on Android by exctrating all the files from a .zip archive into the jniLibs/"abi" subdirectory ("abi" being arm64-v8a for 64-bit ARM, armeabi-v7a for 32-bit ARM, etc.) with the imposed lib___.so filename format expected by the Android platform. Executable files can simply be moved in the right project folder manually, the important part is to use the lib___.so format for the filenames.
In the Android Manifest file, setting the attribute android:extractNativeLibs="true" will get these lib___.so files extracted at installation time in the right native lib directory, with support for execute permission. Symlinks can finally be created if needed in the usual app directory to use the regular executable names, instead of the harder-to-manipulate lib___.so versions.
Thanks, Jérôme
Is there a reference like this (http://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html) that explains the folders inside the main Android SDK folder?
Based on the response I've got so far, I think I need to clarify further what I'm looking for.
I wanted to know the basis for the SDK to be divided into these folders (screenshot below). For e.g. something similar to the following excerpt in the 'SDK Readme.txt'
"Platform-tools contains build tools that are periodically updated to support new features in the Android platform (which is why they are separate from basic SDK tools), including adb, dexdump, and others."
I did put copy the android-sdk folder at a location separate from IDEs so that it can be shared.
It's not a guaranteed standard, but the folders have been consistent for many years now. Here are the core basics, see the links for more info:
# platform-tools: Updated each AOSP version; always backwards compatible
# tools/bin: Platform-independent tools to help building/using android
# eg lint, sdkmanager, monkeyrunner
# build-tools/<version>: Compilation tools, required to build.
# AOSP version specific, typically used by AS directly
See https://developer.android.com/studio/command-line/
https://www.programering.com/a/MDMyMzNwATk.html
No, this is proprietary project from Google, so they don't need to follow any standard.
I am trying to add a map view to my application using Mapsforge. I have done the following:
Downloaded jar files and placed them in the libs/ folder
mapsforge-core-0.4.0.jar
mapsforge-map-0.4.0.jar
mapsforge-map-android-0.4.0.jar
mapsforge-map-reader-0.4.0.jar
Right-clicked file and selected Build Path > Add to Build Path.
In Project Properties, marked the four jars as exported.
However, when I run my app, it crashes on the first call to a class from the library:
E/AndroidRuntime(21265): java.lang.NoClassDefFoundError: org.mapsforge.map.android.graphics.AndroidGraphicFactory
Android SDK tools are all above version 17. No Maven involved.
I've been searching for an answer, but to no avail. I've tried moving the jars up in the list, cleaning the project – this and the things I did already are the essence of what's being suggested on the net. Nothing helped.
When I examine the contents of bin/dexedLibs, I notice that jars for mapsforge were created but are virtually empty, except for the manifest file and (in the case of the maps jar) the osmarender resources. Notably, the classes.dex file is absent. The Android support library in that folder contains a classes.dex file.
Any clues?
EDIT: I examined the original jar files. When looking at the .class files, I noticed each of them starts with CA FE BA BE 00 00 00 33, i.e. is in Java 7 format.
According to some of the information I found on the net, Java 7 is not supported by Android SDK. Is that still the case? This would explain why nothing works but would make me wonder why the Mapsforge devs would use Java 7 to compile a jar that is to be used with Android...
NoClassDefFound is really a hard Exception to solve,a workaround you can try.
workaroud: Java Build Path -> Oeder and Export -> make sur 3rd.jar above yourPath/src
I know android support java7, only when you use the version above 19.
#Ninja pointed me in the right direction but I'll post the detailed steps here.
Short answer: You need version 19 or higher of the Android toolchain, as that version introduced the Java 7 support needed to build against the prebuilt Mapsforge 0.4.0 libraries.
How to update:
Start ADT. Update all installed packages and additionally select at least one version of Android SDK Build-tools that is 19 or higher. (You can have multiple versions of the Android SDK Build-tools installed alongside each other.)
Now open Eclipse and select Help > Check for Updates from the menu.
If you get an error message that no software sources are available, go to Help > Install new software. In the dialog, click Add and add a new repository named ADT Plugin, URL https://dl-ssl.google.com/android/eclipse/. Then retry.
Restart Eclipse when prompted to do so.
Setting the compiler compliance level turned out not to be necessary in my case (I left it at 1.6).
With these steps my Mapsforge project works – I can display a map and the NoClassDefFoundError is gone.
I noticed that the application size of my app, as reported by android, was doubled respect to the same application two months ago, despite I did only minor modifications.
Even building the .apk from the same source code I used two months ago, I obtain a bigger .apk.
I did some investigations and noticed that the classes.dex was way bigger. It seems that something changed in the build environment. Is it possible that the last android SDK causes bigger .dex classes? is it due to something else?
I'm using android SKD inside Eclipse Indigigo:
Android SDK Tools rev. 21
Android SKD Platform-tools rev. 16
Check your resources, Check whether you included or excluded some libraries from the project, Check your .jar files in the project.Clean and build your project.
I'm used to find all SDK resources (such as images, that is what I want) in folder android-sdk>platforms>android-[VERSION_NUMBER]>data>res but I can't find the new android-14 folder.
I've updated all 4.0 tools (as you can see in the image) and the API 14 emulator works
I tried downloading the SDK folder from Android Developer, but it doesn't contain images. How can I access Android 4.0 resources?
Have you tried searching for a folder with the name android-14? I'm thinking the SDK Updater might have placed it elsewhere - all though I don't know why it would have done it.
Since you have the tools installed - the folder should be there. (I have one at least).