Unresolved reference error when importing library - java

I'm having trouble importing this library: https://github.com/javiersantos/MaterialStyledDialogs
I added the repository to my project build.gradle:
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
And added the library to your module build.gradle:
dependencies {
implementation 'com.github.javiersantos:MaterialStyledDialogs:3.0.1'
}
But I get this error, why? i think the issue is because of jcenter, mavencentral or jitpack or such

Add those two lines to your settings.gradle file then sync gradle
pluginManagement {
repositories {
jcenter() // here
maven {url "https://jitpack.io"} // here
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
jcenter() // here
maven {url "https://jitpack.io"} // here
google()
mavenCentral()
}
}

Related

Class referenced in the layout file, `com.hbb20.CountryCodePicker`, was not found in the project or the libraries

I am trying to add CountryCodePicker Class but this error occurs "Class referenced in the layout file, com.hbb20.CountryCodePicker, was not found in the project or the libraries".
build.gradle file:
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.finalyearproject_universityhub"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.hbb20:ccp:2.4.5'
}
XML file:
<com.hbb20.CountryCodePicker
android:id="#+id/countryCode_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
make sure you added jcenter() and maven in build.gradle project level
buildscript {
repositories {
google()
jcenter()
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
In older version past maven { url 'https://jitpack.io' } in build.gradle file.
In Android Studio version 2.1, past maven { url 'https://jitpack.io' } in settings.gradle file like this.
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "FinalYearProject-UniversityHub"
include ':app'
This is because this version add dependencyResolutionManagement in settings.gradle. Here you can add all project repositories. But in older version repositories are added in build.gradle .

sync gradle in android studio 3.6.1

I have tried to sync an android project in android studio 3.6.1 now it shows the ERROR
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'.
AND
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.android.tools.build:gradle:3.6.1.
My gradle-wrapper.properties
#Sat Mar 14 13:13:04 IRST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
My build.gradle
// Top-level build file where you can add configuration options common to all
sub-projects/modules.
buildscript {
repositories {
mavenLocal()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Plugin with id 'gwt' not found

Building libgdx project
First time i got error re-download dependencies and sync project each time i build my project. Then i got the solution from this POST
I did change the following from as instructed from the post
file -> project structure -> project
i. gradle version from 3.3 to 2.14.1
ii. update android studio plugin to 2.2.3 (it was unset)
I did take the values from recent working android project
My build.gradle
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'org.robovm:robovm-gradle-plugin:1.14.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = 'FirstDemo'
gdxVersion = '1.6.4'
roboVMVersion = '1.14.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.4.0'
aiVersion = '1.5.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "org.robovm:robovm-rt:$roboVMVersion"
compile "org.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
}
}
tasks.eclipse.doLast {
delete ".project"
}
Now i am getting error "Plugin with id 'gwt' not found". Can someone please help!
add this dependency into your buildscript tag of your root build.gradle file
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
After addition your buildscript looks like this
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
jcenter()
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'org.robovm:robovm-gradle-plugin:1.14.0'
}
}

Gradle parent project not using child repositories?

That's how I would interpret it. I have a multi-project build with 2 modules: codec and content. When I try to build the project it says it can't find repositories. But when building individual modules, no errors. Also, evaluationDependsOn(':codec') doesn't seem to help.
Could not resolve all dependencies for configuration ':compileClasspath'.
> Cannot resolve external dependency commons-codec:commons-codec:1.5 because no repositories are defined.
Required by:
:multiproject-unified:unspecified > multiproject-unified:codec:unspecified
parent build.gradle:
apply plugin: 'java'
dependencies {
compile project(':codec')
compile project(':content')
}
settings.gradle
include 'codec',
'content'
:codec build.gradle
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'commons-codec:commons-codec:1.5'
}
:content build.gradle
apply plugin: 'java'
repositories {
mavenCentral()
}
Try declaring your repositories for the entire project in the parent:
allprojects {
apply plugin: 'java'
repositories {
mavenCentral()
}
}

Class in main/resources not found

I'm using the Spring Boot gradle plugin to build an executable war. I have a FindResource.java class in src/main/resources to locate files:
FindResource.class.getResource(templateName).toURI()
When I execute gradle build I get an error, that the class FindResource cannot be resolved. Do I need to the the Spring Boot gradle plugin, that it should also use classes from the resources directory. How can I do so?
My build.gradle looks as follows:
buildscript {
ext {
springBootVersion = '1.2.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
jar {
baseName = 'abc'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-jersey")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.apache.pdfbox:pdfbox:1.8.10")
compile('org.apache.poi:poi-ooxml:3.12')
compile('org.apache.poi:poi-scratchpad:3.12')
runtime("org.hsqldb:hsqldb")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
As mentioned in the comment class files to load need to be in src/main/java/ and not in src/main/resources. This link may help give you more information on the convention of this structure.

Categories