Open DavidRobb opened 3 years ago
Yikes. I think this is a JavaPoet bug.
I cannot repro with the following. The generated code compiles. WireField
is imported, so something is forcing the full definition of packages somehow?
syntax = "proto3";
message Simple {
int32 com = 1;
}
OK. I've just tried with a Basic Activity project in Android Studio and yes, the project built with the simple proto file. However, on adding Hilt dependency injection to my project I do get the error:
build.gradle project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
// Top-level variables used for versioning
ext.kotlin_version = '+'
ext.java_version = JavaVersion.VERSION_1_8
version_navigation = "1.0.0"
hilt_version = '2.29-alpha'
}
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.squareup.wire:wire-gradle-plugin:3.5.0'
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_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
}
and build.gradle App:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'com.squareup.wire'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "uk.co.comsci.android.wiretest"
minSdkVersion 21
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
}
kotlinOptions {
jvmTarget = '1.8'
}
}
wire {
// Kotlin target will generate code for services.
kotlin {
rpcRole = 'client'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02'
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
implementation "com.squareup.wire:wire-runtime:3.5.0"
implementation "com.squareup.wire:wire-grpc-client:3.5.0"
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
The following proto file will not build using wire:
Fine if I wasn't so lazy and called my field centre_of_mass ;-)
Generates the follwing errors: