How to build v4 support library from source - android

I'm trying to build the v4 support library from source sice I modified a portion of the library. I'm trying to do this on ubuntu 13.10 with gradle. I followed the instructions in this answer, but now I'm stuck. I used gradle 1.10 with ubuntu since when I tried to build it on windows, it said windows wasn't supported and on ubuntu with gradle 2.4 it said gradle 1.10 was the version that was supported. When I try building with
gradle clean jar --stacktrace
I keep getting an IllegalStateException: llvm-rs-cc is missing, this is a portion of the the stack trace which I keep getting
Caused by: java.lang.IllegalStateException: llvm-rs-cc is missing
at com.android.builder.AndroidBuilder.compileAllRenderscriptFiles(AndroidBuilder.java:1281)
at com.android.builder.AndroidBuilder$compileAllRenderscriptFiles.call(Unknown Source)
at com.android.build.gradle.tasks.RenderscriptCompile.taskAction(RenderscriptCompile.groovy:99)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
The whole stacktrace is here
I tried looking through the source code at AndroidBuilder.java and that hasn't shed any light.
I even tried copying the said llvm-rs-cc file from android-sdk-linux/build-tools to as many folders as I could. I've added the the path to the llvm-rs-cc binary to my path as like the comment in BuildToolInfo.java and also the path to build-tools, tools, and platform-tools which I believe I downloaded using the android sdk manager. I confirmed that the path were added using the printenv command after restarting.
What am I doing wrong?

It turns out that that that I needed to edit the local.properties file in plaform/frameworks/support to add the sdk directory, i.e
sdk.dir=/path/to/android-sdk-linux/
Adding this actually made the whole llvm-rs-cc shenenigans disappear but... there's more
The stackoverflow answer that I was following said to use this command
platform\frameworks\support\v4\gradle clean jar
which I interpreted to mean navigate to the v4 directory then call gradle with
gradle clean jar
Here are the *complete steps I followed in case anybody wants to built the support library also.
First, follow the instructions in this answer:
You need to checkout additional repositories from
https://android.googlesource.com:
platform/frameworks/support
platform/prebuilts/gradle-plugin
platform/prebuilts/maven_repo/android
platform/prebuilts/sdk
platform/prebuilts/tools
Please, keep the directory structure as in android repository.
Install the packages lib32stdc++6 and lib32z1, I used apt-get
sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1
Download the android sdk from the android developer website here
Unpack the archive to any location then navigate to it then to tools\
run ./android this should lainch the sdk manager then download these packafes if they're not already downloaded
All android api from api 4 to api 22 (You may need to show obsolete packages).
Build tools 19.01 (You may need to show obsolete packages) and the most recent build tools
Most recent Platform tools
Most recent SDK tools
Normally this should be sufficient to build the support library with gradle, but it turns out that the jar file in the git repository for api 22 is actually not up to date as it doesn't contain the new AccessibilityInfo methods that were added in api 22, yes I decompiled it to be sure. So a few more steps.
Replace the andoid.jar file in platform/prebuilts/sdk/current that you downloaded from the git repository with the one from android-sdk-linux/platforms/android-22/
We're almost done here but two more issues. If you try to build the library now there'll be two compiltion errors in Fragment.java and in FragmentActivity.java feel free to fix these however you like, since I'm not sure how correct my fix for these were.
To fix these, in Fragment.java on line #935 I added a cast so
result.setFactory(mChildFragmentManager.getLayoutInflaterFactory());
became this
result.setFactory((LayoutInflater.Factory)mChildFragmentManager.getLayoutInflaterFactory());
For the other fix, in FragmentActivity.java on line #299 I replaced
final View v = mFragments.onCreateView(name, context, attrs);
with this
final View v = mFragments.onCreateView(null, name, context, attrs);
The reason for adding the null there was because in the previous versions the first parameter, which is View parent didn't exist and in the onCrateView method parent was declared and initialized to null.
The resulting jar file can be found in platform/out/host/gradle/frameworks/support/support-v4/build/libs/
*Some steps may be missing, as this process took me a long time, and I may have forgotten some things I did.

Try this:
compile files('libs/your.jar')

eclipse help linkv4 support library help for building gradle

Related

Can't mach build Fennec for Android

i'm following this tutorial from firefox android source code https://wiki.mozilla.org/Mobile/Fennec/Android
but, the problem i can't ./mach build, ./mach package, ./mach install and i already create .mozconfig file in mozilla-central but it's can't found the file.
like this:
i'm using Ubuntu 14.04.2
thx for help
You probably had an error during the initial "mach bootstrap" step. Your screenshot tells us, that mach can't find the android sdk tools. It's looking for them under ~/.mozbuild/android-sdk-linux/.
One thing you could do is to manually put your sdk under that directory and then retry "mach bootstrap" from the source dir to resolve the remaining dependencies.
Also see these steps for manual setup of the build tools: https://wiki.mozilla.org/Mobile/Fennec/Android/Detailed_build_instructions

Error executing aapt: Return code 132 problems

Since updating my Android SDK about a month ago I've had endless problems leaving me with a non-functional development environment.
Initially the problem was with the v7-appcompat support library which threw up about 100 errors relating to various resources. It was fairly obvious they were resources relating to Android v5 and a quick search on Stack Overflow meant I realised the v7-appcompat library was targeting API 19. Changing the relevant settings to target API 21 fixed the resource errors.
However, the problem I've had since then is any attempt to build the library project quickly finishes with...
Error executing aapt: Return code 132
...and the library project isn't built correctly.
My original setup was with Eclipse Kepler but then I tried Android Studio v1.0.1 (same aapt error code) and today I installed Eclipse Luna to a separate directory from Kepler AND a fresh installation of ADT and SDK. Each version of Eclipse also have their own workspaces.
So basically I have two versions of Eclipse (each with their own ADT / SDK setups and workspaces) and Android Studio with its own directory structure and all three exhibit the same problem.
The question is, how do I go about diagnosing this issue? The common denominator is obviously an aapt issue but I have no idea how to fix it.
I'm running on a Debian Wheezy (32-bit) setup and I've got Java 1.7 installed correctly (as recommended).
There seems to be an issue with aapt on some 32 bit systems. It throws an error 132 on app:processDebugResources which is when aapt is 'crunching' png files ready for inclusion in the apk package. You can see more details at https://code.google.com/p/android/issues/detail?id=75110
Some people have reported that 'fixing' the offending png files (e.g. by opening in Gimp and saving) sorts the problem. When they are 'built in' to appcompat it's much harder to do of course.
Before getting into detail can you just say if you are indeed running on a 32 bit processor, and if so which one? use lscpu to find out.
OK, if anyone is interested, here is a work around so you can use your old laptop to build apps with Android Studio. Basically you strip all the png files in the appcompat-v7 library and then do a build using two versions of aapt. Yuk.
Find the appcompat-v7.aar which will be somewhere like ~/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/22.0.0
Extract it (it's a zip file really) to a temporary directory
Strip all the png files: find . -name "*.png" -exec mogrify -strip {} \;
Pack the files back up again: pushd appcompat-v7-22.0.0; zip -r ../appcompat-v7-22.0.0.aar; popd
Move the new aar file to replace the original (that may be enough to get a good build but it wasn't for me)
Now find an old version of aapt (I went to https://dl-ssl.google.com/android/repository/build-tools_r17-linux.zip)
Copy the version of aapt from the zip you've just picked up into the Android/Sdk/build-tools directory as aapt-17 or whatever
Rename the original aapt to aapt-0
Alternate between the two versions of aapt (e.g. ln -sf aapt-17 aapt) and you should find you can get a good build. One version will fail in one place, the other in another, getting you past all the bumps.
I know it stinks but I was desperate!!
Here's what I did, which is enough to get a successful build. Inspired by peterthevicar's answer.
downgrade sdk to 19.1.0, you can install it from studio and then change buildToolsVersion in build.gradle
rename aapt to aapt.bin and put a shell script in its place that intercepts just the png crunch (args: s -i infile -o outfile) and does a simple cp instead. would paste it here but SO's syntax highlighting suuuucks

Eclipse - Cannot complete the install because one or more required items could not be found (org.apache.httpcomponents.httpclient)

I am trying to install Eclipse Git Team Provider and JGit in my version of Eclipse ADT via Help > Install New Software > "EGit - http://download.eclipse.org/egit/updates" but the installation fails with this error...
Cannot complete the install because one or more required items could
not be found. Software being installed: Java implementation of Git -
optional Http support using Apache httpclient 3.3.1.201403241930-r
(org.eclipse.jgit.http.apache.feature.group 3.3.1.201403241930-r)
Missing requirement: Apache HttpComponents HttpClient OSGi bundle
4.1.3.v201209201135 (org.apache.httpcomponents.httpclient 4.1.3.v201209201135) requires 'package org.apache.commons.codec.binary 1.4.0' but it could not be found Cannot satisfy dependency:
From: Java implementation of Git - optional Http support using Apache httpclient 3.3.1.201403241930-r
(org.eclipse.jgit.http.apache.feature.group 3.3.1.201403241930-r)
To: org.apache.httpcomponents.httpclient [4.1.3.v201209201135]
It's saying I need to install either org.apache.httpcomponents.httpclient 4.1.3.v201209201135 or package org.apache.commons.codec.binary 1.4.0 (although, I'm not clear which one is missing, or whether both are missing?)...
How do I add it/them to Eclipse?
I can find lots of info on how to add jars to the library of an individual project, but that's not what I need as I think (correct me if I'm wrong) that I need to add them to Eclipse via Help > Install New Software.
And I have seen lots of people post similar problems with other dependencies, but have not found an answer that explains how to add this particular software.
I'm new to Eclipse, so any help would be much appreciated.
I have found a solution to this problem, at least on my installation of Eclipse.
What I did was get the name of the missing package and googled it.
Download the package from here:
http://commons.apache.org/proper/commons-codec/download_codec.cgi
Selecting the package under the "Binaries" section
Unzip the file and extract "commons-codec-1.9.jar"
Copy this Jar file to your Eclipse installation directory "Eclipse\plugins"
Rename it with the name of your missing package.
(In my case "org.apache.commons.codec.binary_1.4.0.jar")
Now repeat the steps to install EGit and it should work.
Obviously there are many things that could be different with your installation, I am using Eclipse version 4.2.0
I hope this helps.
I'm using Eclipse SDK Version: 4.2.2 and I faced the same problem as user1617737.
It's a little obscure but I dare say the missing dependency is 'package org.apache.commons.codec.binary 1.4.0'. I guess there is a problem with this JAR file in the EGit package itself.
Anyway, I was unable to find a solution, other than unmarking the following component to be installed:
Java implementation of Git - optional Http support using Apache httpclient 3.3.2.201404171909-r
In this way, EGit has been installed, though I don't know what features I may be missing.
I had the same problem. I deleted an older version of org.apache.commons.codec.binary from the clipse/plugins directory. And placed the required "org.apache.commons.codec.binary 1.4.0.jar". Then it worked.
I gave up in the end and used Eclipse Kepler, which worked fine.
Would be nice to know the solution though to the original problem if anyone knows it. I'm sure others will also get this problem.
I have the same problem with Eclipse Indigo Version: 3.7.2. I tried to install older versions of EGit but still I had other problems. Finally EGit version 1.3 was installed with success.

Android Library Dependencies broken after SDK/ADT-Update

Today, I updated my Android SDK and Eciple ADT to the most recent versions (ADT Rev 22). After restarting Eclipse it is quite unhappy with the Build Paths whenever I reference custom libraries.
An example is shown in this screenshot:
My custom "Android Utilities Library" compiles fine, but everything that depends on it shows build path errors. E.g. when I investigate the build path settings for "Android URA Library" it shows me an error with the android_utilities_library.jar missing under "Android Dependencies" (which in fact is true, the libraries will be built to individual class files in bin/classes).
After reading the solution to Build path errors with library projects I tried to clean and manually build my projects in the correct order, but to no avail.
I've never dealt with this before, so I don't know how to attack the problem.
Any help is appreciated. Thx!
Installing the new Build Tools did the trick. They were not automatically included when I updated the SDK (probably need to run the update twice I guess).
I found a solution that works for me:
Go to Project Properties > Build Path > Order and Export
Then you have to check each checkbox.
In my case my libraries were restored
I hope it will help.
I can see that your project Android URA Library is referring to Android Utilities Library, then the problem should not relate to SDK/ADT update.
Please check:
Project Properties of Android URA Library, choose Project tab and make sure you added Android Utilities Library as dependency project. Otherwise, please add it.
If the problem is still existing, then Projects \ Clean All Projects
Go to libraries and check the build path of the dependent libraries. It should be same as your projects build path.
if you have import all the Dependencies in your workSpace.maybe you can:projetc-->build all.
I meet the problem,and it works well

NoClassDefFoundError when running Instrumentation test with ant

(This is an Android SDK tools v17 problem. Expect a fix in v18)
I have a test target project A, and a tester project B.
Project A has FlurryAgent.jar in its libs folder.
Project B has robotium-solo-3.1.jar in its libs folder
When I compile and run them,
cd A
android update project -p .
cd ..
cd B
android update test-project -p . -m ../A
ant all clean debug
ant uninstall
ant installt
ant test
ant test fails to execute tests:
test:
[echo] Running tests ...
[exec]
[exec] com.example.r17.test.TestOne:
[exec] INSTRUMENTATION_RESULT: shortMsg=java.lang.NoClassDefFoundError
[exec] INSTRUMENTATION_RESULT: longMsg=java.lang.NoClassDefFoundError: com.flurry.android.FlurryAgent
[exec] INSTRUMENTATION_CODE: 0
I've read some posts/questions that solve this problem in Eclipse. But I don't think I can run Eclipse on headless Jenkins slave.
Since this post was the first in search engine results when I entered "java.lang.NoClassDefFoundError: com.flurry.android.FlurryAgent" and my issue was not related to Ant at all, I thought I'd add some info for people who might be scratching their heads after re-installing the ADT.
Basically, in Eclipse when you add an external library in the Java Build Path dialog, don't forget to also switch to the Order and Export tab and tick that library's name in the list. This is needed so that the library is found at run-time, not only at compile time :)
http://code.google.com/p/android/issues/detail?id=27608
I submitted the issue to Google and they uploaded a temporary fix. The fix will also be included in v18 release.
"project member x...#android.com, Today (34 minutes ago)
get the anttasks.jar from the bottom of http://tools.android.com/download to replace the one in your sdk."
The file to replace is at \Android\android-sdk\tools\lib\
It took me a very long time to figure this same problem out when using android-junit-report, but with the help of "adb logcat" I discovered that it wasn't actually missing the instrumentation class that I included, but it was missing its inherited superclass. So I needed to put this back into AndroidManifest.xml:
<application>
<uses-library android:name="android.test.runner" />
</application>
I dont have the rep to comment Qi but I think this may be related to my question here:
VerifyError in android test-project build tools v17
Xav has been instrumental in getting this back up and running and looks like hes got a fix
I have the same case and it doesn't work even if I followed Levon's post. Then I realized I need to copy the FlurryAnalytics.jar into the libs folder in my work space to make it work. Hope this helps.
I have just fix this problem "08-14 08:33:43.398: E/AndroidRuntime(6748): java.lang.NoClassDefFoundError: com.flurry.android.FlurryAgent"
I flow the official web when I want to add the flurry to my android app,it tell me add an external library in the Java Build Path dialog, And then I don't forget to also switch to the Order and Export tab and tick that library's name in the list. This is needed so that the library is found at run-time, not only at compile time,But however it do not works until I just remove the jar from build path,and then copy it to the lib. Done!!!

Categories

Resources