Android: jar package into the system required to Android studio

General system interface is a modified hide behind class

1. For the modified file AIDL, jar packet according to the required coding information is known.

  mmm /frameworks/base/ show commands > log.txt 2>&1

  out / target / common / obj / JAVA_LIBRARIES / framework_intermediates / classes.jar (frameworks.jar is dex format, the original ecological non-Java file)

2. Import classes.jar to Android studio project:

 The system module jar package into the libs folder, under the Module build.gradleto add:

 

provided files('libs/classes.jar')


Or graphics as follows:

 

 

 

 

 

 

 

 

 

Under the Project build.gradlefile, add:

  gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs.add('-Xbootclasspath/p:app/libs/android_framework.jar')         
    }
}

 

To modify the priority:

allprojects {
    repositories {
        JCenter ()
    }
 
    // add the following code to the classes-full-debug.jar packages are built prior to the android.jar
  gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs.add('-Xbootclasspath/p:setting\\libs\\frameworks.jar') } } }

Module to find the corresponding lower .iml, manually modify the order of introduction jar package

The Android SDK put the final configuration items, otherwise the system will still not able to find API:

 

 

3. Compile error:

a. java.lang.OutOfMemoryError: GC overhead limit exceeded

Android Studio Google jar causing GC overhead limit exceeded error
http://stackoverflow.com/questions/25013638/android-studio-google-jar-causing-gc-overhead-limit-exceeded-error

Solution: build.gradleadd:

dexOptions {
    javaMaxHeapSize "4g"
}


b. Too many field references

Building Apps with Over 65K Methods
https://developer.android.com/tools/building/multidex.html

Solution:

    defaultConfig {

        // Enabling multidex support.
        multiDexEnabled true
    }

 

dependencies {

    compile 'com.android.support:multidex:1.0.0'

}

  AndroidManifest.xml 中添加:android:name="android.support.multidex.MultiDexApplication"

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.thisway.app_0001_leddemo" >

    <application
        android:name="android.support.multidex.MultiDexApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

 

Supplementary: scop amended as Provided, not only involved in compiling packaged into apk.

Provided Files ( 'libs / Full-debug.jar-classes')    at the rear, Provided is an alternative  Android studio3.0compileOnly

 

 Print specify TAG / grade log: logcat LedHal: I *: S

 

 

4. Q. service using reflection

import android.os.IBinder;

 

        try {
            //iLedService = ILedService.Stub.asInterface(ServiceManager.getService("led"));
            Method getService = Class.forName("android.os.ServiceManager").getMethod("getService", String.class);
            LedService Object = getService.invoke ( null , " LED " ); // static object is first parameter can be NULL, call the Invoke IBinder up-converted to Object, if used IBinder return required cast
            Method asInterface = Class.forName("android.os.ILedService$Stub").getMethod("asInterface", IBinder.class);
            proxy = asInterface.invoke(null, ledService);
            ledCtrl = Class.forName("android.os.ILedService$Stub$Proxy").getMethod("ledCtrl", int.class, int.class);  //设置第i盏灯熄灭: ledCtrl.invoke(proxy, i, 0);
        } catch (NoSuchMethodException e) {
            e.printStackTrace ();
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        } catch (IllegalAccessException e) {
            e.printStackTrace ();
        } catch (InvocationTargetException e) {
            e.printStackTrace ();
        }

    

 

Guess you like

Origin www.cnblogs.com/blogs-of-lxl/p/11756466.html