Summary of small knowledge points2019-9-16

1. The use of aar files

(1) Add the following configuration to build.gradle of app

android{
    
    
......
}

// 配置下
repositories {
    
    
    flatDir {
    
    
        dirs 'libs'
    }
}


dependencies {
    
    
......
}

(2) Copy the aar file to the app/libs directory (for example, test.aar)

(3) Introduced in app's build.gradle

implementation(name: 'test', ext: 'aar')
2. Use of jar and module

(1)jar

1. Put the jar package into the lib folder
2. Studio file add as library can be
ps:

  • You can also put the jar package into the lib folder and directly import the syntax in the corresponding gradle file (the effect is the same as above)
  • You can also put the jar package into the lib folder and introduce it through project scructure (the effect is the same as above)

(2) Module dependency

  • Studio creates a new module (if the name is test), the app project needs to depend on test

1. Create a new module
2. Add dependencies to the app build

 /**
     * 此处的括号不可省略,groovy允许在 顶级表达式 中可以省略方法的括号。
     * 某些情况下是不可省略的。我们尽量不省略为好。
    * */
    implementation project (":autotrackappviewscreensdk")
  • Import third-party modules

In fact, it is one step more configuration than the self-built studio

Insert picture description here

3. Obtain the app version number

  /**
     * get App versionName
     * @param context
     * @return
     */
    public String getVersionName(Context context){
    
    
        PackageManager packageManager=context.getPackageManager();
        PackageInfo packageInfo;
        String versionName="";
        try {
    
    
            packageInfo=packageManager.getPackageInfo(context.getPackageName(),0);
            versionName=packageInfo.versionName;
        } catch (PackageManager.NameNotFoundException e) {
    
    
            e.printStackTrace();
        }
        return getResources().getString(R.string.version)+" " +versionName;
    }

There are a lot of package information in PackageInfo

4. Debug failed to successfully hit the official package

(1)log

Warning: there were 2 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.

Quick solution, add confusion: -ignorewarnings try

(2) Other reasons

It may be caused by confusing files, check it.

5. The code pulled by the remote warehouse does not report an error, but it cannot run

Possible reason:
project local.propertry (the file is your local sdk path configuration) file is missing, the run button of the project is grayed out.
Solution:
find a project to copy

6. Check the sha1 MD5 of the app

Open cmd

keytool -list -keystore jks file path (you can find the file and drag it into cmd)

7、Android resource linking failed

(1) Problems arise

I've run a good project before, and I will open it for a run in a few days.

(2)log

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDevDebugResources'.
> Android resource linking failed
  Output:  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2386: error: resource anim/abc_popup_enter (aka com.multiple.scanner.plus.nmd:anim/abc_popup_enter) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2387: error: resource anim/abc_popup_exit (aka com.multiple.scanner.plus.nmd:anim/abc_popup_exit) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2390: error: resource anim/abc_grow_fade_in_from_bottom (aka com.multiple.scanner.plus.nmd:anim/abc_grow_fade_in_from_bottom) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2391: error: resource anim/abc_shrink_fade_out_from_bottom (aka com.multiple.scanner.plus.nmd:anim/abc_shrink_fade_out_from_bottom) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2394: error: resource anim/abc_tooltip_enter (aka com.multiple.scanner.plus.nmd:anim/abc_tooltip_enter) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2395: error: resource anim/abc_tooltip_exit (aka com.multiple.scanner.plus.nmd:anim/abc_tooltip_exit) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2558: error: resource color/abc_btn_colored_borderless_text_material (aka com.multiple.scanner.plus.nmd:color/abc_btn_colored_borderless_text_material) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2561: error: resource color/abc_btn_colored_text_material (aka com.multiple.scanner.plus.nmd:color/abc_btn_colored_text_material) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2615: error: resource drawable/abc_list_selector_holo_dark (aka com.multiple.scanner.plus.nmd:drawable/abc_list_selector_holo_dark) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2667: error: resource drawable/abc_list_selector_holo_dark (aka com.multiple.scanner.plus.nmd:drawable/abc_list_selector_holo_dark) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2699: error: resource color/abc_background_cache_hint_selector_material_dark (aka com.multiple.scanner.plus.nmd:color/abc_background_cache_hint_selector_material_dark) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2702: error: resource color/abc_primary_text_material_dark (aka com.multiple.scanner.plus.nmd:color/abc_primary_text_material_dark) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2703: error: resource color/abc_primary_text_material_light (aka com.multiple.scanner.plus.nmd:color/abc_primary_text_material_light) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2704: error: resource color/abc_primary_text_disable_only_material_dark (aka com.multiple.scanner.plus.nmd:color/abc_primary_text_disable_only_material_dark) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2705: error: resource color/abc_secondary_text_material_dark (aka com.multiple.scanner.plus.nmd:color/abc_secondary_text_material_dark) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2706: error: resource color/abc_secondary_text_material_light (aka com.multiple.scanner.plus.nmd:color/abc_secondary_text_material_light) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2707: error: resource color/abc_secondary_text_material_dark (aka com.multiple.scanner.plus.nmd:color/abc_secondary_text_material_dark) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2708: error: resource color/abc_secondary_text_material_light (aka com.multiple.scanner.plus.nmd:color/abc_secondary_text_material_light) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2709: error: resource color/abc_hint_foreground_material_dark (aka com.multiple.scanner.plus.nmd:color/abc_hint_foreground_material_dark) not found.
  E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\mergeDevDebugResources\merged.dir\values\values.xml:2710: error: resource color/abc_hint_foreground_material_light (aka com.multiple.scanner.plus.nmd:color/abc_hint_foreground_material_light) not found.
  
  Command: C:\Users\Avazu Holding\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\9b77b5b42259ae47c6f73ccea7616b21\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
          E:\AsSDK\platforms\android-28\android.jar\
          --manifest\
          E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\merged_manifests\devDebug\processDevDebugManifest\merged\AndroidManifest.xml\
          -o\
          E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\processed_res\devDebug\processDevDebugResources\out\resources-devDebug.ap_\
          -R\
          @E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\incremental\processDevDebugResources\resources-list-for-resources-devDebug.ap_.txt\
          --auto-add-overlay\
          --java\
          E:\ASWorkPlace\MultipleScannerPlus\app\build\generated\not_namespaced_r_class_sources\devDebug\processDevDebugResources\r\
          --custom-package\
          com.android.scanner.master.plus\
          -0\
          apk\
          --output-text-symbols\
          E:\ASWorkPlace\MultipleScannerPlus\app\build\intermediates\symbols\dev\debug\R.txt\
          --no-version-vectors
  Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

(3) Some files of the cause analysis system cannot be found

(4) Try to solve the update of the gradle version

It is said on the Internet that there are some bugs in gradle, I updated to the recommended 3.4.2 and then ojbk

Insert picture description here

8. android:fullBackupContent="" related issues

(1) A bug appears after connecting to an SDK in the background

* What went wrong:
Execution failed for task ':app:processDevDebugManifest'.
> Manifest merger failed : Attribute application@fullBackupContent value=(@xml/vungle_backup_rule) from [com.github.vungle:vungle-android-sdk:6.3.24] AndroidManifest.xml:16:9-60
  	is also present at [:function_karmaSdk.1.0.2:] AndroidManifest.xml:66:9-66 value=(@xml/app_full_back_up_content).
  	Suggestion: add 'tools:replace="android:fullBackupContent"' to <application> element at AndroidManifest.xml:10:5-53:19 to override.

(2) Analysis

It can be seen from the log that the two dependencies have their own manifest files, and the android:fullBackupContent="" of their application node has different attribute values.

(3) Resolution

        android:fullBackupContent="@xml/app_full_back_up_content"
        tools:replace="android:fullBackupContent"

Add attribute substitution to the application node under your app's manifest file. We can replace the value according to our conflicting choice.

end

Guess you like

Origin blog.csdn.net/qq_38350635/article/details/100937972