How to create a v4 support library from source

I am trying to create a v4 support library from the source system, I modified part of the library. I am trying to do this on ubuntu 13.10 using gradle. I followed the instructions in this answer , but now I'm stuck. I used gradle 1.10 with ubuntu, because when I tried to create it on windows, he said that windows are not supported, and on ubuntu with gradle 2.4 he said that gradle 1.10 was a supported version. When I try to create using

gradle clean jar --stacktrace 

I keep getting IllegalStateException: llvm-rs-cc is missing, this is part of the stack trace 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) 

Whole stacktrace here

I tried to view the source code of AndroidBuilder.java and did not shed any light. I even tried to copy the specified llvm-rs-cc file from android-sdk-linux/build-tools to as many folders as I could. I added the path to the llvm-rs-cc binary to my path, as a comment in BuildToolInfo.java , as well as the path to build-tools, tools, and platform-tools , which I assume was loaded using the android sdk manager. I confirmed that the path was added using the printenv command after the restart.

What am I doing wrong?

+7
android compilation gradle android-support-library
source share
3 answers

It turns out 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 led to the disappearance of all shennigans llvm-rs-cc, but ... there is more

The answer to stackoverflow that I used said to use this command

 platform\frameworks\support\v4\gradle clean jar 

which I interpreted as meaning going to the v4 directory and then calling gradle with

 gradle clean jar 

Here are the complete steps that I followed if someone also wants to create a support library.

  • First follow the instructions in this:

You need to check the additional repositories https://android.googlesource.com :

  • platform / framework / support
  • platform / prebuilts / gradle -plugin
  • Platform / prebuilts / maven_repo / android
  • Platform / prebuilts / SDK
  • Platform / prebuilts / tools

Please keep the directory structure as in the Android repository.

  1. Install lib32stdc++6 and lib32z1 , I used apt-get

    sudo apt-get install lib32stdc++6

    sudo apt-get install lib32z1

  2. Download android sdk from the Android developer website here

  3. Unzip the archive to any place, then go to it, then to tools\

  4. Run ./android , this should hide the sdk manager, and then download these packages if they are not already loaded

    • All android api from api 4 to api 22 (You may need to show outdated packages).
    • Build Tools 19.01 (You may need to show deprecated packages) and the latest build tools
    • The latest platform tools
    • Latest SDK Tools

Usually this is enough to create a support library using gradle, but it turns out that the jar file in the git repository for api 22 is not actually updated, because it does not contain the new AccessibilityInfo methods that were added in api 22, yes, I decompiled it to be sure. So a few more steps.

  1. Replace the andoid.jar file in the platform/prebuilts/sdk/current that you downloaded from the git repository named android-sdk-linux/platforms/android-22/

We are almost done here, but two more problems. If you try to build the library now, there will be two compilation errors in FragmentActivity.java and in FragmentActivity.java do not hesitate to fix them as you like, since I'm not sure how correct my fix is ​​for them.

To fix them, in Fragment.java on line # 935 I added a listing like this

 result.setFactory(mChildFragmentManager.getLayoutInflaterFactory()); 

has become

 result.setFactory((LayoutInflater.Factory)mChildFragmentManager.getLayoutInflaterFactory()); 

For another 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 a null value was that in previous versions, the first parameter, which is the View parent , did not exist and was declared and initialized to be null in the onCrateView parent method.

The resulting jar file can be found in platform/out/host/gradle/frameworks/support/support-v4/build/libs/ * Some steps may be missing, because this process took me a lot of time, and I may have forgotten some things, which i did.

+9
source share

Try the following:

  compile files('libs/your.jar') 
0
source share
-one
source share

All Articles