I have recently updated my Android Studio to latest version. But the gradle file here seems bit different.
here is the gradle code :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}
I want to add these below jitsi lines in the project gradle file. how should I paste it so that it syncs properly without any errors.
here is the jitsi code :
allprojects {
repositories {
maven {
url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
}
google()
mavenCentral()
maven { url 'https://www.jitpack.io' }
}
}
I have tried changing the gradle file by adding or replacing the above lines, Nothing changes. It is throwing an error.
As you appear to be using the recently revised build configuration scripts, you should be able to declare your repositories under the settings.gradle file:
pluginManagement {
// Plugin repositories go here
}
// ...
dependencyResolutionManagement {
/**
* The dependencyResolutionManagement {repositories {...}}
* block is where you configure the repositories and dependencies used by
* all modules in your project, such as libraries that you are using to
* create your application. However, you should configure module-specific
* dependencies in each module-level build.gradle file. For new projects,
* Android Studio includes Google's Maven repository and the Maven Central
* Repository by default, but it does not configure any dependencies (unless
* you select a template that requires some).
*/
// The following line makes it so that project modules (such as your
// "app" module) can't declare their own repositories {} block
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
// Add your repositories here...
maven {
url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
}
maven { url 'https://www.jitpack.io' }
}
}
only buildscript {}, pluginManagement {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed
As for this error, this is because plugins blocks are always resolved first, and so any other code must be declared after that block:
// There shouldn't be any code before this!
plugins {
}
// Okay to have build script code here...
Android studio latest version you move the jitsi repository in the project's settings.gradle file
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
mavenLocal()
}
}
Related
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}
this is only what i see in my build.gradle project. Im trying add this code (to get some custom toast cause the toast.view is deprecated):
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
but i cant see allprojects{} and the rest of things that should be there
There are different ways of defining repositories in Gradle. Recently, projects created in the Android Studio wizard no longer include an allProjects block in build.gradle. They configure the dependency repositories in a dependencyResolutionManagement block in the settings.gradle file. For example:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
When I add firebase perf dependency into my project i am getting this error Illegal class file: Class module-info is missing a super type. Class file version 53.
My Gradle and google services project-level dependencies are
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.3.2'
and I followed the exact steps mentioned in their docs https://firebase.google.com/docs/perf-mon/get-started-android.
I have tried clean and rebuild and clearing the Android Studio cache.
And also tried similarly issue resolution from StackOverflow
Project level build gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.3.2'
classpath 'com.google.firebase:perf-plugin:1.3.1' // Performance Monitoring plugin
}
}
allprojects {
repositories {
google()
jcenter()
}
}
App level build gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
jcenter()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.31.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
// Apply the Performance Monitoring plugin to enable instrumentation
apply plugin: 'com.google.firebase.firebase-perf'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
maven {
url 'https://maven.google.com'
}
}
dependencies {
// Not added all dependencies , Just the firebase one SINCE ITS PRETTY LONG
implementation 'com.google.firebase:firebase-perf:19.0.0'
}
Adding this to your app-level build.gradle file solves the problem temporarily
debug {
FirebasePerformance {
// Set this flag to 'false' to disable #AddTrace annotation processing and
// automatic HTTP/S network request monitoring
// for a specific build variant at compile time.
instrumentationEnabled false
}
}
EDIT as per other answers and comments
Change the gradle plugin to 3.6.0 to resolve it as it has been fixed in that version
FYI, this was an AGP bug...it's been fixed in AGP 3.6
On updating build Gradle from 3.5.1 to 3.6.0 fixed my issue.
Also remove this from gradle.properties if you happen to have it there for any reason:
android.enableR8=false
(I got the error even with com.android.tools.build:gradle:4.1.2 if the above line was present)
I have been many issues with the new Android Studio release (3.2.1) when I try to build the project.
I'm working with android-sunflower (jetpack integration) project and I'm getting the following error.
Is someone else getting this error?
Plugin [id: 'com.diffplug.gradle.spotless', version: '3.13.0'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.diffplug.gradle.spotless:com.diffplug.gradle.spotless.gradle.plugin:3.13.0')
Searched in the following repositories:
Gradle Central Plugin Repository
Open File
Adapt this for your top level build.gradle file for your project . Add plugins and spotless.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.diffplug.gradle.spotless" version "3.4.0"
}
allprojects {
repositories {
jcenter()
}
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
}
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
java {
target "**/*.java"
trimTrailingWhitespace()
removeUnusedImports()
googleJavaFormat()
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Spotless documentary say this for using it:
To use it in your buildscript, just add the Spotless dependency, and
configure it like so:
spotless {
format 'misc', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
trimTrailingWhitespace()
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
format 'cpp', {
target '**/*.hpp', '**/*.cpp'
replace 'Not enough space after if', 'if(', 'if ('
replaceRegex 'Too much space after if', 'if +\\(', 'if ('
// Everything before the first #include or #pragma will
// be replaced with whatever is in `spotless.license.cpp`
licenseHeaderFile 'spotless.license.cpp', '#'
}
}
I've deployed artifact to bintray as it whitten in documentation (using their plugin). All looks fine. It is opened in browder, structure looks fine: https://dl.bintray.com/flymob/maven/
Now I want to use it via gradle in Android Studio before publishing to jcenter(). I've read their documentation https://bintray.com/docs/usermanual/formats/formats_mavenrepositories.html#_working_with_gradle
I've tried:
buildscript {
repositories {
jcenter()
maven {
url "https://dl.bintray.com/flymob/maven"
}
}
}
and
compile 'flymob-sdk-sample:FlyMobSdk:1.3.0'
or
compile 'flymob-sdk-sample:FlyMobSdk:1.3.0#aar'
I'm getting error:
Failed to resolve: flymob-sdk-sample:FlyMobSdk:1.3.0
What am I doing wrong?
you added "https://dl.bintray.com/flymob/maven" inside the buildscript section. Those are the repos used by the buildscript (a.k.a. gradle script) only. Those are the repos where the system will find the plugins from apply plugin
to fix it is easy. Just move it to the repositories on the "root" of the script. Something like:
buildscript {
repositories {
// repos for the build script
jcenter()
... etc
}
dependencies {
// dependencies from the plugins from the build script
classpath 'com.android.tools.build:gradle:2.1.2'
... etc
}
}
apply plugin: 'android-sdk-manager'
apply plugin: ... etc
repositories {
jcenter()
maven { url "https://dl.bintray.com/flymob/maven" } <<<<< HERE
}
dependencies {
compile ... etc
So our group has a private maven repository with a large number of libraries 'in-house'. So there only available on a vpn. bintray and jcenter is available on my vpn. What i want to do is have gradle check for a dependency first on the private maven repo, if not found then search bintray/jcenter for the library. How can i do this ? this is what i have tried:
In the top level build.gradle file i have:
buildscript {
repositories {
maven { url "https://myprivateRepo.com/libraries"
}
jcenter()
}
my assumption was that it would first check maven private repo and then check with jcenter afterwards but it seems to not be working, can anyone verify the set up ?
You're adding the repositories for your buildscripts (or plugins). You need to add it to your project / dependencies level.
Using it with buildscript will resolve plugins. You need that e.g. if you are using apt: apply plugin: 'com.neenbedankt.android-apt'
Remove the wrapping buildscript block:
repositories {
maven { url "https://myprivateRepo.com/libraries" }
mavenCentral()
jcenter()
}
dependencies {
compile "my:library:1.0.0"
// ...
}
Alternatively just set it on the project root build.gradle and apply to all projects like this
allprojects {
repositories {
maven { url "https://myprivateRepo.com/libraries" }
mavenCentral()
jcenter()
}
}