I have a root project with three subprojects
root
|
|-subA
|-subB
|-subB
the build.gradle file in root has this content
allprojects {
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'org.zeromq:jeromq:0.3.+'
compile files('../lib/tibrvj.jar')
}
eclipse {
classpath {
downloadJavadoc=true
}
}
sourceSets {
main.java.srcDirs = ['src/main/java']
main.resources.srcDirs = ['src/main/resources']
test.java.srcDirs = ['src/test/java']
test.resources.srcDirs = ['src/test/resources']
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2'
}
task srcDirs << {
subprojects.sourceSets.main.java.srcDirs.each{f -> println(f)}
subprojects.sourceSets.main.resources.srcDirs.each{f -> println(f)}
subprojects.sourceSets.test.java.srcDirs.each{f -> println(f)}
subprojects.sourceSets.test.resources.srcDirs.each{f -> println(f)}
}
I do not know how I can create all the directories with this config. The other gradle.build files are empty at the moment
Unless you're trying to change from the defaults, you shouldn't need to set the sourceSets directories in the subprojects.
Have you tried something like:
subprojects {
task makeSrcDirs << {
sourceSets.main.java.srcDirs*.mkdirs()
sourceSets.main.resources.srcDirs*.mkdirs()
sourceSets.test.java.srcDirs*.mkdirs()
sourceSets.test.resources.srcDirs*.mkdirs()
}
}
Related
I am trying to run the flutter application on the android studio before now all works perfectly but after I changed my targetSdkVersion to targetSdkVersion 31 I started getting this error that says
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.google.firebase:firebase-core:25.12.0.
Required by:
project :app
> No cached version of com.google.firebase:firebase-core:25.12.0 available for offline mode.
And google-services.json is available in my project. My pubspec.yaml for firebase_message is firebase_messaging: ^7.0.3, android/build.gradledependencies is
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
mavenCentral() // Maven Central repository
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
``` and my ```app/build.gradle``` dependencies is
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-analytics'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-core:11.0.4'
implementation platform('com.google.firebase:firebase-bom:31.0.2')
}
Thanks, in advance, please let me know if there is any information is needed
I tried to clean the project, pub upgrade, pub get, flutter upgrade, and even tried downloading a new version of firebase_messaging and pasting it inside the project still the same error.
So I was able to solve this by first updating my firebase_messaging version in pubspec.yaml to firebase_messaging: ^13.0.4 And android/build.gradle dependencies is
buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
mavenCentral() // Maven Central repository
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.13'
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
//details.useVersion "1.0.1"
details.useVersion "1.5.0"
}
}
}
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral() // Maven Central repository
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And and my app/build.gradle dependencies is
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 33
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "appname"
minSdkVersion 20
//noinspection OldTargetApi
multiDexEnabled true
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-analytics'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:multidex:1.0.3'
implementation platform('com.google.firebase:firebase-bom:31.0.2')
}
The above solved the issue for me.
add build.repositories jcenter() and to allprojects.repositories jcenter(), in your build.gardle file
This is my build.gradle file:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlinkotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
I know that I can change the gradle:4.1.0 to the required gradle version
and then change the distributionUrl present in the gradle-wrapper.properties. But every time I create a new project I get the the same old version 4.1.0 and then I have to manually change it again. How can I set a default version for it?
Go to app/build.gradel
add this
android {
compileSdkVersion 31 // <-- This
defaultConfig {
applicationId "com.example.app"
targetSdkVersion 31 // <-- and this too
// ...
}
}
Recently i get the following build error on flutter:
Could not determine the dependencies of task ':app:processDebugResources'.
Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
Could not resolve com.google.android.gms:play-services-ads-base:[19.7.0].
Required by:
project :app > project :google_mobile_ads > com.google.android.gms:play-services-ads:19.7.0
project :app > project :google_mobile_ads > com.google.android.gms:play-services-ads:19.7.0 > com.google.android.gms:play-services-ads-lite:19.7.0
project :app > project :google_mobile_ads > com.google.android.gms:play-services-ads:19.7.0 > com.google.android.gms:play-services-gass:19.7.0
> Failed to list versions for com.google.android.gms:play-services-ads-base.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-base/maven-metadata.xml.
> Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-base/maven-metadata.xml'.
> Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-base/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
I believe this is due to bintray being depreciated. This is my android/build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
mavenCentral()
google()
// jcenter()
// maven {
// url 'https://dl.bintray.com/android/android-tools'
// }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
mavenCentral()
google()
//
// jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have replaced jcenter with mavenCentral, cleared cache and ran flutter clean but i still receive the same error
This is my app level build.gradle:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29 // used to be 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.eventr_app_2021"
minSdkVersion 19
targetSdkVersion 29
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.google.firebase:firebase-messaging:21.0.1'
implementation 'com.google.android.gms:play-services-basement:18.0.0' //used to be 17.4.0
}
apply plugin: 'com.google.gms.google-services'
// Work around for onesignal-gradle-plugin compatibility
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck =
true
A domain object is setup as the following:
#Data
#NoArgsConstructor
#Entity
public class Foo {
...
public Foo(...){
...
}
...
}
It is fine when I run a build with a set of tests. When I only run the test class, however, I get the following error:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: No default constructor for entity: : com.abc.myapp.Foo; nested exception is org.hibernate.InstantiationException: No default constructor for entity: : com.abc.myapp.Foo
The project setup is with Spring Boot generated by the project generator on spring.io. And the following is the Gradle build file:
buildscript {
ext {
springBootVersion = '1.5.0.RC1'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle- plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'spring-data-samples'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-actuator-docs')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-data-rest')
runtime('org.springframework.boot:spring-boot-devtools')
runtime('com.h2database:h2')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
}
And IDE is Intellij Idea.
What is missing?
I created by this post,I genarate the Entity,Dao,DaoMaster and DaoSession ,but I can't import these class?
How can I do this?My android project has a java module in android studio,I generated the src-gem in my android project,and I can't add the src folder as java sources folder.
build.gradle
android {
sourceSets {
main {
java.srcDirs = ['src/main/java','src-gem']
}
}
}
It's work.
For GreenDao 3 add this to android section of app's gradle:
sourceSets {
main {
java.srcDirs = ['src/main/java', 'build/generated/source/greendao']
}
}
If the Entity, Dao, DaoMaster and DaoSession were generated.
Add the below code into build.gradle of your project:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId "com.example.paduy.greendaoforandroidstudio"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'src/main/java-gen']
res.srcDirs = ['src/main/res']
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'de.greenrobot:greendao:1.3.7'
}
Reference link
In my case it's work
build.gradle
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
android { ..... }
greendao {
schemaVersion 1
targetGenDir 'src/main/java'
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'build/generated/source/greendao']
}
}
dependencies {
.............
.............
compile 'org.greenrobot:greendao:3.2.2'
}