I had success generating protobuf code to java using java-lite, problem is that I need plain 'java'
Project level:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
// 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
}
Module level:
plugins {
id 'com.android.application'
id "com.google.protobuf" version "0.8.13"
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.maartin.myapplication"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.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
}
sourceSets.main.java.filter.exclude 'META-INF/**/*'
packagingOptions {
exclude 'META-INF/**/*'
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:2.0.3'
implementation "androidx.appcompat:appcompat:1.2.0"
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "androidx.datastore:datastore-core:1.0.0-alpha02"
implementation "com.google.protobuf:protobuf-javalite:3.13.0"
}
sourceSets {
main {
java {
srcDirs 'build/generated/source/proto/main/grpc'
srcDirs 'build/generated/source/proto/main/java'
srcDir 'src/main/proto'
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.10.0'
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option 'lite'
}
}
}
}
}
Code on top is working flawlessly, but generates javalite version. How can I generate simple java?
What I tried:
Project level: stays the same
Module level:
plugins {
id 'com.android.application'
id "com.google.protobuf" version "0.8.13"
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.maartin.myapplication"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled 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
}
packagingOptions {
pickFirst "META-INF/io.netty.versions.properties"
pickFirst "META-INF/INDEX.LIST"
exclude 'META-INF/*'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/native-image/io.netty/transport/native-image.properties'
exclude 'META-INF/native-image/io.netty/codec-http2/native-image.properties'
exclude 'META-INF/native-image/io.netty/codec-http2/*'
exclude 'META-INF/native-image/io.netty/codec-http2/*'
exclude 'META-INF/native-image/io.netty/buffer/native-image.properties'
exclude 'META-INF/native-image/io.netty/handler/native-image.properties'
exclude 'META-INF/native-image/io.netty/*'
exclude 'META-INF/native-image/io.netty/common/native-image.properties'
exclude 'META-INF/native-image/io.netty/transport/reflection-config.json'
exclude 'META-INF/native-image/io.netty/codec-http/native-image.properties'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
}
sourceSets.main.java.filter.exclude 'META-INF/**/*'
packagingOptions {
exclude 'META-INF/**/*'
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:2.0.3'
implementation "androidx.appcompat:appcompat:1.2.0"
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "androidx.datastore:datastore-core:1.0.0-alpha02"
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.12.0'
implementation group: 'io.grpc', name: 'grpc-all', version: '1.29.0'
}
sourceSets {
main {
java {
srcDirs 'build/generated/source/proto/main/grpc'
srcDirs 'build/generated/source/proto/main/java'
srcDir 'src/main/proto'
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.11.0'
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.29.0'
}
}
generateProtoTasks {
all()*.plugins {
grpc {
outputSubDir = 'java'
}
}
}
}
With new approach - I do not run into errors, but build/generated/source/proto has only debug folder (java files are not generated)
I suspect the following part is problematic.
grpc {
outputSubDir = 'java'
}
It overrides the output directory name for the grpc plugin to java. However, 'java' directory is the default directory for the java builtin. The consequence of this is that the generated gRPC service code overwrites the generated Java message code. Can you try changing it to something else or just leave it for default?
Related
**Could not parse the android application modules gradle config firebase.
I don't know what to do,this is the first project.And I really can't solve it.
I've seen quite a lot of people getting this error, but it seems that they could solve it by upgrading their build tool version, or by updating google-services. I've done all that and haven't been able to make it work so far.
Here are my Gradle scripts:**
build.gradle(project)
buildscript {
ext.kotlin_version = '1.6.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(module)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
}
apply plugin: 'kotlin-android'
android {
compileSdk 32
defaultConfig {
applicationId "com.example.simplechatkotlin"
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
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation platform('com.google.firebase:firebase-bom:30.0.0')
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.firebase:firebase-database:20.0.5'
implementation 'com.google.firebase:firebase-common-ktx:20.1.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "androidx.core:core-ktx"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
The Kotlin Gradle plugin version should match the Kotlin version you're using, so it should be 1.6.21. And the latest build tools version is 7.1.2.
buildscript {
ext.kotlin_version = '1.6.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
classpath 'com.google.gms:google-services:4.3.10'
}
}
I get a "Cannot resolve symbol" error whenever I try to import the classes below.
io.realm.ObjectServerError;
io.realm.SyncCredentials;
io.realm.SyncUser;
but not when I try to import
io.realm.RealmQuery;
io.realm.RealmResults;
io.realm.Realm;
I have added
realm{
syncEnabled = true
}
in my app build.gradle but it still shows the same error.
Here is my app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
realm{
syncEnabled = true
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.ktoon"
minSdkVersion 17
targetSdkVersion 30
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 fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Here is my project build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "io.realm:realm-gradle-plugin:10.0.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
}
What am I missing?
There was a number of breaking changes to the API in 10.0.0. Among them, SyncUser was renamed to io.realm.mongodb.User. See https://github.com/realm/realm-java/blob/master/CHANGELOG.md#1000-2020-10-15 for the full list
AndroidManifest.xml Error: Package name
'android.support.graphics.drawable' used in:
com.android.support:animated-vector-drawable:28.0.0,
com.android.support:support-vector-drawable:28.0.0
https://imgur.com/6aFUN59
https://imgur.com/C1EmnJ3
An error happened after upgrade Android Studio 3.4
Already try change compileSdk to 27 / 27.1.1 but still same
and already try to disable "vector-drawable" lib but still same
.
.
.
.
.
.
.
.
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public'}
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.1'
classpath 'com.google.firebase:firebase-plugins:1.2.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'
android {
compileSdkVersion 28
defaultConfig {
applicationId "xxx.packacge.name"
minSdkVersion 21
targetSdkVersion 28
versionCode 4
versionName "Dev"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
applicationVariants.all { variant ->
//variant.getAssembleProvider()
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
buildToolsVersion = '28.0.3'
}
repositories {
mavenCentral()
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
configurations.all {
exclude group: 'com.android.support', module: 'support-v13'
}
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha5'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-fragment:28.0.0'
}
apply plugin: 'com.google.gms.google-services'
..
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
maven {
url 'https://maven.google.com/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.firebase:firebase-plugins:1.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
..
You should try this way
implementation('com.android.support:support-vector-drawable:28.0.0') {
exclude group: 'android.support.graphics.drawable'
exclude module: 'support-vector-drawable'
}
implementation('com.android.support:support-vector-drawable:28.0.0') {
exclude group: 'android.support.graphics.drawable'
exclude module: 'support-vector-drawable'
}
try this one
In my Android project (Kotlin), I want to use Room persistent library for my DATA LAYER.
But when I added dependencies for Room Persistent library suddenly build projects start failing.
Error which I am receiving:
Here is my project level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
globalCompileSdkVersion = 26
globalMinSdkVersion = 19
globalTargetSdkVersion = 26
kotlin_version = '1.2.10'
support_version = "27.0.2"
constraint_layout_version = "1.0.2"
view_animator_version = "1.0.5"
junit_version = "4.12"
runner_version = "1.0.1"
espresso_core_version = "3.0.1"
room_version = "1.0.0"
dagger_version = "2.13"
rxJavaVersion = "2.1.7"
rxAndroidVersion = "2.0.1"
libs = [
appCompatV7 : "com.android.support:appcompat-v7:$support_version",
rxJava : "io.reactivex.rxjava2:rxjava:$rxJavaVersion",
rxAndroid : "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion",
junit : "junit:junit:$junit_version",
runner : "com.android.support.test:runner:$runner_version",
espressoCore: "com.android.support.test.espresso:espresso-core:$espresso_core_version"
]
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}
Here is my app module build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion project.globalCompileSdkVersion
defaultConfig {
applicationId "com.keepsafe.app"
minSdkVersion project.globalMinSdkVersion
targetSdkVersion project.globalTargetSdkVersion
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation libs.appCompatV7
implementation "com.android.support:design:$support_version"
implementation "com.android.support.constraint:constraint-layout:$constraint_layout_version"
implementation "com.github.florent37:viewanimator:$view_animator_version"
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
implementation libs.rxJava
implementation libs.rxAndroid
testImplementation libs.junit
androidTestImplementation libs.runner
androidTestImplementation libs.espressoCore
implementation project(":data")
implementation project(":domain")
}
Here is my domain module build.gradle
apply plugin: 'java-library'
apply plugin: 'kotlin'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation libs.rxJava
implementation libs.rxAndroid
implementation libs.junit
}
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
Here is my data module build.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
android {
compileSdkVersion project.globalCompileSdkVersion
defaultConfig {
minSdkVersion project.globalMinSdkVersion
targetSdkVersion project.globalTargetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "android.arch.persistence.room:runtime:$room_version"
implementation "android.arch.persistence.room:rxjava2:$room_version"
kapt "android.arch.persistence.room:compiler:$room_version"
testImplementation libs.junit
implementation project(":domain")
}
repositories {
mavenCentral()
}
I don't know how to resolve this issue.
Your help will be appreciated.
Android Gradle Plugin 3.0 and higher added a new behaviour for dependencies. You can read more about this here. Long story short, by using implementation in a submodule you're not sharing a dependency with a consumer module(your app module). Thus, it's not possible to generate the code needed for Room.
Essentially, what you need to do is simply change implementation to api in your data module for the Room's dependencies. The result will be:
api "android.arch.persistence.room:runtime:$room_version"
api "android.arch.persistence.room:rxjava2:$room_version"
Gradle stop build task when click any gradle task on Android Studio 2.2.3.
There's no error on screen or any error message
What I'm doing wrong ?
Some additional data
Android Studio 2.2.3
Gradle 'com.android.tools.build:gradle:2.2.3'
Gradle top level build file
buildscript {
repositories {
jcenter()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects{
repositories {
jcenter()
jcenter()
}
}
This is my build.gradle file.
def final myapplicationId = "com.package.myapp"
def final versionnameapp = "1"
def final versioncodeapp = 1
allprojects {
repositories {
// mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
}
}
apply plugin: 'com.android.application'
configurations {
compile.exclude group: 'javax.inject', module: 'javax.inject'
}
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileOptions {
encoding "UTF-8"
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
dexOptions {
jumboMode true
}
signingConfigs {
release {
keyAlias 'chess'
keyPassword 'android'
storeFile file('/keystore/sam.keystore')
storePassword 'android'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/ASL2.0'
}
defaultConfig {
targetSdkVersion 23
renderscriptTargetApi 19
renderscriptSupportModeEnabled false
multiDexEnabled true
minSdkVersion 14
applicationId = myapplicationId
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
defaultConfig {
debuggable true
versionName = versionnameapp + "-DEBUG"
}
}
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex'
// dx.additionalParameters += "--main-dex- list=$projectDir/multidex.keep".toString()
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':reportes')
compile project(':locationlib')
compile 'com.android.support:percent:23.3.0'
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
compile 'joda-time:joda-time:2.3'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
compile 'ch.acra:acra:4.5.0'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.github.panwrona:DownloadProgressBar:1.1'
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.cleveroad:slidingtutorial:0.9.5'
}
Thanks in advance
Execute gradlew assemble from the command-line. There you will get the error that you are missing.