Solution to Failed to Resolve when AndroidStudio configures LitePal or Unresolved package 'litepal' when configuring AndroidManifest files

Problems encountered when initializing LitePal · Issue #787 · guolindev/LitePal · GitHub

The above is the same problem as me

Recently, when I was learning the first line of code, when I needed to introduce LitePal, Class referenced in the manifest, org.litepal.LitePalApplication, was not found in the project or the libraries appeared in the Manifest file.

android:name="org.litepal.LitePalApplication"

Since org, it has been reported to be popular, and I have been working on it for an afternoon and a night, and I have almost given up. When I look at the Build below,

 Discover

Then try to run again (I tried countless times, and I wanted to give up at the time)

 

I found that I couldn't connect to the website in the picture above, so I tried to search again (and again countless times) how to add a mirror warehouse, but the problem was solved by mistake.

Okay, after all the whining, let me tell you how to fix this damn problem. As long as the corresponding settings.gradle in the root directory of the project

 

Add the corresponding position of the small red box 

jcenter()
maven { url 'https://jitpack.io' }

After adding it, don’t forget to introduce the sentence of LitePal in the app’s build.gradle

implementation 'org.litepal.guolindev:core:3.2.3'

Delete the sync, add it back and sync again, then we will find that the problem has been solved! ! ! ! ! ! ! !

If it still can't be solved, I also added these lines of code to build.gradle in the project root directory (the one outside the app directory)

 

buildscript {

    repositories {
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}

        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

This is the code to add the mirror warehouse, which should solve the problem, because I found the LitePal project in the mirror warehouse (the ghost knows how many things I searched in that afternoon and one night-manual tear collapse)

Finally, guess the possible reason is that jcenter is deprecated, and then LitePal was updated to version 3.2.3 in August 2021. At that time, jcenter may not be deprecated, and the latest version of AndroidStudio does not import dependencies from Jcenter, resulting in the inability to import LitePal , It's really deceitful! ! ! ! ! ! ! ! ! ! ! ! .

Guess you like

Origin blog.csdn.net/qq_42924347/article/details/123809960