OneUIProject / oneui-design

Samsung's One UI design components for Android apps.
MIT License
146 stars 17 forks source link

Android resource linking failed #2

Closed WORLD8848 closed 2 years ago

WORLD8848 commented 2 years ago

Hello. I am checking the usability of OneUIProject/oneui-design.

I did the test as follows.

  1. Below, the dependencies portion is annotated on build.gradle(:sample-app) and build.gradle(:lib).

    // implementation("io.github.oneuiproject.sesl:appcompat:$sesl_appcompat_version") // implementation("io.github.oneuiproject.sesl:material:$sesl_material_version") // implementation("io.github.oneuiproject.sesl:recyclerview:$sesl_recyclerview_version")

  2. I generated the aar file with the assembleRelease command for each unit module in OneUIProject/sesl. The aar files were then included in Sample-app, lib via the Implementation files command.

  3. Gradle sync now runs successfully.

  4. When I run the sample-app, an error occurs as below.

Please give me some advice to solve these errors. Thank you.

### Android resource linking failed ERROR:/EX_ONEUI_SAMPLE_20220526/sample-app/build/intermediates/incremental/debug/mergeDebugResources/merged.dir/values/values.xml:6393: AAPT: error: style attribute 'attr/cardBackgroundColor (aka com.sec.sesl.tester:attr/cardBackgroundColor)' not found.

ERROR:/EX_ONEUI_SAMPLE_20220526/sample-app/build/intermediates/incremental/debug/mergeDebugResources/merged.dir/values/values.xml:6394: AAPT: error: style attribute 'attr/cardCornerRadius (aka com.sec.sesl.tester:attr/cardCornerRadius)' not found.

ERROR:/EX_ONEUI_SAMPLE_20220526/sample-app/build/intermediates/incremental/debug/mergeDebugResources/merged.dir/values/values.xml:6395: AAPT: error: style attribute 'attr/cardElevation (aka com.sec.sesl.tester:attr/cardElevation)' not found.

salvogiangri commented 2 years ago

As I already told you, you don't have to build the aars, adding the dependencies is already enough: your IDE will download the binaries from the maven central repository. Try to build the app without modifying any file (just by cloning the repo in your PC and opening the project) and let me know what happens

WORLD8848 commented 2 years ago

Thank you from the bottom of my heart for your reply.

I am interested in the various usability of the open library, so I am trying various things. And I shared some simple experiences.

Wouldn't this experience make a better library?

I will share it here when a good solution is found.

salvogiangri commented 2 years ago

Again, I don't see why you should compile the artifacts if you didn't do any modifications to them. Also, the way you added the dependencies in your project will not import the .aar files you compiled but instead will download them from the maven repo, to import your custom .aars you actually have to use this line:

dependencies {
    //implementation 'io.github.oneuiproject.sesl:appcompat:1.0.0'
    //implementation 'io.github.oneuiproject.sesl:material:1.0.0'

    implementation fileTree(include: ['*.aar'], dir: 'libs')

}

This will import all the .aar libraries inside your project's "libs" folder. Regarding the build error, seems like something's off with the material library (the missing attrs are from that lib). Could you send me your app/build.gradle file so I can see if there's something off in it?

WORLD8848 commented 2 years ago

Thanks!!

I fully understand how to use the library you shared.

I share the requested information.

build.gradle(:lib) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

plugins { id 'com.android.library' // id 'com.vanniktech.maven.publish' }

android { compileSdk target_sdk

defaultConfig {
    minSdk 23
    targetSdk target_sdk
    versionCode 1
    versionName lib_version

    vectorDrawables.useSupportLibrary = true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
    main.res.srcDirs += "src/main/res-icons"
}

}

dependencies {

implementation fileTree(include: ['*.aar'], dir: 'libs')    

api("androidx.annotation:annotation:$androidx_annotation_version")

// api("io.github.oneuiproject.sesl:appcompat:$sesl_appcompat_version") // implementation("io.github.oneuiproject.sesl:indexscroll:$sesl_indexscroll_version") // implementation("io.github.oneuiproject.sesl:preference:$sesl_preference_version") // implementation("io.github.oneuiproject.sesl:material:$sesl_material_version")

implementation files('libs/AppCompat-1.0.0.aar')
implementation files('libs/AppPickerView-1.0.0.aar')
implementation files('libs/CoordinatorLayout-1.0.0.aar')
implementation files('libs/Core-1.0.0.aar')
implementation files('libs/CustomView-1.0.0.aar')
implementation files('libs/DrawerLayout-1.0.0.aar')
implementation files('libs/Fragment-1.0.0.aar')
implementation files('libs/IndexScroll-1.0.0.aar')
implementation files('libs/Material-1.0.1.aar')
implementation files('libs/Picker-Basic-1.0.0.aar')
implementation files('libs/Picker-Color-1.0.0.aar')
implementation files('libs/Preference-1.0.0.aar')
implementation files('libs/RecyclerView-1.0.1.aar')
implementation files('libs/SlidingPanelLayout-1.0.0-Alpha01.aar')
implementation files('libs/SwipeRefreshLayout-1.0.0.aar')
implementation files('libs/ViewPager-1.0.0.aar')
implementation files('libs/ViewPager2-1.0.0.aar')
implementation 'androidx.activity:activity:1.4.0'

}

ext { POM_NAME = "One UI Design" POM_DESCRIPTION = "One UI Design Library." }

build.gradle(:sample-app) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

plugins { id 'com.android.application' }

// Exclude Google AndroidX. configurations.all { exclude group: 'androidx.appcompat', module: 'appcompat' exclude group: 'androidx.core', module: 'core' }

android { compileSdk target_sdk

defaultConfig {
    // Use Samsung internal package name to enable theming.
    applicationId "com.sec.sesl.tester"

    minSdk 23
    targetSdk target_sdk

    versionCode sample_version_code
    versionName sample_version_name
}

buildFeatures {
    buildConfig true
    viewBinding true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {

implementation fileTree(include: ['*.aar'], dir: 'libs')

// api("androidx.annotation:annotation:$androidx_annotation_version") // implementation("io.github.oneuiproject.sesl:appcompat:$sesl_appcompat_version") // implementation("io.github.oneuiproject.sesl:material:$sesl_material_version") // implementation("io.github.oneuiproject.sesl:recyclerview:$sesl_recyclerview_version") implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'com.airbnb.android:lottie:5.0.3' implementation project(path: ':lib')

////////////////////////////////////////////////////////////////////////////////////////////////////

implementation files('libs/AppCompat-1.0.0.aar')
implementation files('libs/AppPickerView-1.0.0.aar')
implementation files('libs/CoordinatorLayout-1.0.0.aar')
implementation files('libs/Core-1.0.0.aar')
implementation files('libs/CustomView-1.0.0.aar')
implementation files('libs/DrawerLayout-1.0.0.aar')
implementation files('libs/Fragment-1.0.0.aar')
implementation files('libs/IndexScroll-1.0.0.aar')
implementation files('libs/Material-1.0.1.aar')
implementation files('libs/Picker-Basic-1.0.0.aar')
implementation files('libs/Picker-Color-1.0.0.aar')
implementation files('libs/Preference-1.0.0.aar')
implementation files('libs/RecyclerView-1.0.1.aar')
implementation files('libs/SlidingPanelLayout-1.0.0-Alpha01.aar')
implementation files('libs/SwipeRefreshLayout-1.0.0.aar')
implementation files('libs/ViewPager-1.0.0.aar')
implementation files('libs/ViewPager2-1.0.0.aar')

}

salvogiangri commented 2 years ago

Everything seems fine (you don't need to import every .aar file since with that one line I told you to add it does add all of them automatically). Are you still having the same issue?

WORLD8848 commented 2 years ago

The result is the same even if you annotate the bottom part.

implementation files('libs/AppCompat-1.0.0.aar') implementation files('libs/AppPickerView-1.0.0.aar') implementation files('libs/CoordinatorLayout-1.0.0.aar') implementation files('libs/Core-1.0.0.aar') implementation files('libs/CustomView-1.0.0.aar') implementation files('libs/DrawerLayout-1.0.0.aar') implementation files('libs/Fragment-1.0.0.aar') implementation files('libs/IndexScroll-1.0.0.aar') implementation files('libs/Material-1.0.1.aar') implementation files('libs/Picker-Basic-1.0.0.aar') implementation files('libs/Picker-Color-1.0.0.aar') implementation files('libs/Preference-1.0.0.aar') implementation files('libs/RecyclerView-1.0.1.aar') implementation files('libs/SlidingPanelLayout-1.0.0-Alpha01.aar') implementation files('libs/SwipeRefreshLayout-1.0.0.aar') implementation files('libs/ViewPager-1.0.0.aar') implementation files('libs/ViewPager2-1.0.0.aar')

image

salvogiangri commented 2 years ago

Did you try to compile the original project without any modification as I suggested?

WORLD8848 commented 2 years ago

I tried compiling the Original Project without any modifications to the contents mentioned above.

Below is an image with an error message.

image

Therefore, the following contents were added to the dependencies section of the build.gradle(:lib).

import androidx.activity.OnBackPressedCallback;

image

Then, the above-mentioned [Android resource linking failed] error occurs.

salvogiangri commented 2 years ago

Did you check if this error could be caused by the nonTransitiveRClass flag like it did in the old library?

salvogiangri commented 2 years ago

I totally forgot about the most stupid thing we could've tried😂: try to add the androidx cardview dependency in your build.gradle file:

implementation 'androidx.cardview:cardview:1.0.0'
WORLD8848 commented 2 years ago

The above has been reflected.

The above has been reflected. Then, a new error appeared.

I am sharing the relevant information with the image below.

Thank you.


build.gradle(:lib) image

build.gradle(:sample-app) image

gradle.properties image

WORLD8848 commented 2 years ago

Did you check if this error could be caused by the nonTransitiveRClass flag like it did in the old library?

gradle.properties

add: android.nonTransitiveRClass=true

image

A new error occurs that is different from the above mentioned error

image

salvogiangri commented 2 years ago

I think I found your issue: you're still using custom built .aars in your project, in this way you have to manually declare all the dependencies of each sesl lib module on your build.gradle files. As I said, try to avoid using custom .aar files and use the artifacts in the maven repository. If you still wish to use custom artifacts I suggest you to compile the sesl library using the maven local repository instead