Android Studio duplicate generated files - android-studio

Android studio keeps creating generated classes, even though they already exist.
The problem has something to do with the NavigationArgs I guess but it always gives some error of duplication.
The only way that solves my problem now is to clean the entire project every time before I run the app.
Does anyone know how to fix this, how do I know which implementation is causing this error?
Gradle Project
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.3.2'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.0-beta01"
classpath ('com.google.firebase:firebase-plugins:1.1.0') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle Module
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: "androidx.navigation.safeargs"
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.umbrella.budgetapp"
minSdkVersion 28
targetSdkVersion 28
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'])
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.palette:palette:1.0.0'
implementation 'com.google.android.material:material:1.1.0-beta01'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta05'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.github.ronaldsmartin:Material-ViewPagerIndicator:1.0.4'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
implementation 'com.firebaseui:firebase-ui-firestore:5.0.0'
implementation 'com.google.firebase:firebase-auth:19.1.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.jakewharton:butterknife:10.2.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
implementation 'org.jetbrains:annotations:15.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.bumptech.glide:glide:4.10.0'
}
Build output
> Task :app:compileDebugJavaWithJavac
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/buildConfig/debug/com/umbrella/budgetapp/BuildConfig 2.java:6: error: class BuildConfig is public, should be declared in a file named BuildConfig.java
public final class BuildConfig {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/buildConfig/debug/com/umbrella/budgetapp/BuildConfig.java:6: error: duplicate class: com.umbrella.budgetapp.BuildConfig
public final class BuildConfig {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/IconsDirections 4.java:9: error: class IconsDirections is public, should be declared in a file named IconsDirections.java
public class IconsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/GoalDetailsDirections 6.java:9: error: class GoalDetailsDirections is public, should be declared in a file named GoalDetailsDirections.java
public class GoalDetailsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/GoalsReachedDirections 4.java:16: error: class GoalsReachedDirections is public, should be declared in a file named GoalsReachedDirections.java
public class GoalsReachedDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/PlannedPaymentsDirections 4.java:16: error: class PlannedPaymentsDirections is public, should be declared in a file named PlannedPaymentsDirections.java
public class PlannedPaymentsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/PlannedPaymentsDirections.java:16: error: duplicate class: com.umbrella.budgetapp.Layouts.Fragments.PlannedPaymentsDirections
public class PlannedPaymentsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/GoalsReachedDirections.java:16: error: duplicate class: com.umbrella.budgetapp.Layouts.Fragments.GoalsReachedDirections
public class GoalsReachedDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/GoalsPausedDirections 4.java:16: error: class GoalsPausedDirections is public, should be declared in a file named GoalsPausedDirections.java
public class GoalsPausedDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/ShoppingListItemsArgs 4.java:13: error: class ShoppingListItemsArgs is public, should be declared in a file named ShoppingListItemsArgs.java
public class ShoppingListItemsArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/GoalsActiveDirections 5.java:16: error: class GoalsActiveDirections is public, should be declared in a file named GoalsActiveDirections.java
public class GoalsActiveDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/DebtsBorrowedDirections 5.java:16: error: class DebtsBorrowedDirections is public, should be declared in a file named DebtsBorrowedDirections.java
public class DebtsBorrowedDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/ShoppingItemsArgs 4.java:13: error: class ShoppingItemsArgs is public, should be declared in a file named ShoppingItemsArgs.java
public class ShoppingItemsArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/ShoppingListItemsDirections 4.java:16: error: class ShoppingListItemsDirections is public, should be declared in a file named ShoppingListItemsDirections.java
public class ShoppingListItemsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/StatisticsBalanceDirections 7.java:9: error: class StatisticsBalanceDirections is public, should be declared in a file named StatisticsBalanceDirections.java
public class StatisticsBalanceDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/DebtsLentDirections 5.java:16: error: class DebtsLentDirections is public, should be declared in a file named DebtsLentDirections.java
public class DebtsLentDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/ShoppingListItemsArgs.java:13: error: duplicate class: com.umbrella.budgetapp.Layouts.Fragments.ShoppingListItemsArgs
public class ShoppingListItemsArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/ShoppingListsDirections 4.java:17: error: class ShoppingListsDirections is public, should be declared in a file named ShoppingListsDirections.java
public class ShoppingListsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/GoalDetailsArgs 5.java:13: error: class GoalDetailsArgs is public, should be declared in a file named GoalDetailsArgs.java
public class GoalDetailsArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/GoalDetailsDirections.java:9: error: duplicate class: com.umbrella.budgetapp.Layouts.Fragments.GoalDetailsDirections
public class GoalDetailsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/StatisticsCashflowDirections 4.java:9: error: class StatisticsCashflowDirections is public, should be declared in a file named StatisticsCashflowDirections.java
public class StatisticsCashflowDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/StoresDirections 4.java:16: error: class StoresDirections is public, should be declared in a file named StoresDirections.java
public class StoresDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/IconsDirections.java:9: error: duplicate class: com.umbrella.budgetapp.Layouts.Fragments.IconsDirections
public class IconsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/Fragments/GoalsPausedDirections.java:16: error: duplicate class: com.umbrella.budgetapp.Layouts.Fragments.GoalsPausedDirections
public class GoalsPausedDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateUserProfileDirections 10.java:8: error: class UpdateUserProfileDirections is public, should be declared in a file named UpdateUserProfileDirections.java
public class UpdateUserProfileDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateDebtDirections 4.java:9: error: class UpdateDebtDirections is public, should be declared in a file named UpdateDebtDirections.java
public class UpdateDebtDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateAccountDirections 4.java:9: error: class UpdateAccountDirections is public, should be declared in a file named UpdateAccountDirections.java
public class UpdateAccountDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateCategoryArgs 6.java:13: error: class UpdateCategoryArgs is public, should be declared in a file named UpdateCategoryArgs.java
public class UpdateCategoryArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateCategoryDirections 4.java:9: error: class UpdateCategoryDirections is public, should be declared in a file named UpdateCategoryDirections.java
public class UpdateCategoryDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateGoalDetailsDirections 9.java:8: error: class UpdateGoalDetailsDirections is public, should be declared in a file named UpdateGoalDetailsDirections.java
public class UpdateGoalDetailsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateGoalDetailsDirections 10.java:8: error: class UpdateGoalDetailsDirections is public, should be declared in a file named UpdateGoalDetailsDirections.java
public class UpdateGoalDetailsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdatePlannedPaymentArgs 8.java:13: error: class UpdatePlannedPaymentArgs is public, should be declared in a file named UpdatePlannedPaymentArgs.java
public class UpdatePlannedPaymentArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateGoalDetailsArgs 8.java:14: error: class UpdateGoalDetailsArgs is public, should be declared in a file named UpdateGoalDetailsArgs.java
public class UpdateGoalDetailsArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateCurrencyDirections 7.java:9: error: class UpdateCurrencyDirections is public, should be declared in a file named UpdateCurrencyDirections.java
public class UpdateCurrencyDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateTemplateArgs 7.java:13: error: class UpdateTemplateArgs is public, should be declared in a file named UpdateTemplateArgs.java
public class UpdateTemplateArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdatePlannedPaymentArgs 9.java:13: error: class UpdatePlannedPaymentArgs is public, should be declared in a file named UpdatePlannedPaymentArgs.java
public class UpdatePlannedPaymentArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateGoalDetailsArgs 9.java:14: error: class UpdateGoalDetailsArgs is public, should be declared in a file named UpdateGoalDetailsArgs.java
public class UpdateGoalDetailsArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateDebtDirections.java:9: error: duplicate class: com.umbrella.budgetapp.Layouts.UpdateFragments.UpdateDebtDirections
public class UpdateDebtDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateGoalSelectDirections 9.java:16: error: class UpdateGoalSelectDirections is public, should be declared in a file named UpdateGoalSelectDirections.java
public class UpdateGoalSelectDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateStoreArgs 7.java:13: error: class UpdateStoreArgs is public, should be declared in a file named UpdateStoreArgs.java
public class UpdateStoreArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateAccountArgs 7.java:13: error: class UpdateAccountArgs is public, should be declared in a file named UpdateAccountArgs.java
public class UpdateAccountArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdatePlannedPaymentDirections 7.java:9: error: class UpdatePlannedPaymentDirections is public, should be declared in a file named UpdatePlannedPaymentDirections.java
public class UpdatePlannedPaymentDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateUserProfileDirections 8.java:8: error: class UpdateUserProfileDirections is public, should be declared in a file named UpdateUserProfileDirections.java
public class UpdateUserProfileDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateRecordDetailsDirections 9.java:8: error: class UpdateRecordDetailsDirections is public, should be declared in a file named UpdateRecordDetailsDirections.java
public class UpdateRecordDetailsDirections {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateDebtArgs 9.java:13: error: class UpdateDebtArgs is public, should be declared in a file named UpdateDebtArgs.java
public class UpdateDebtArgs implements NavArgs {
^
/Users/XX/Documents/AndroidStudio/Projects/BudgetApp/app/build/generated/source/navigation-args/debug/com/umbrella/budgetapp/Layouts/UpdateFragments/UpdateShoppingListDirections 9.java:9: error: class UpdateShoppingListDirections is public, should be declared in a file named UpdateShoppingListDirections.java
public class UpdateShoppingListDirections {
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
100 errors
> Task :app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

go to the menu and choose: Build -> Clean Project, and once done, Build -> Rebuild project

If click Build -> Clean project or Rebuild project cannot fix the issue, there should be another issue lead to build failed. Fix other issue and rebuild could succeed.
Also check if there exists a real BuildConfig file in the package, delete it and try again.

you may have created duplicate java files of same name and kind, check well and delete one.

Related

UnsatisfiedResolutionException - CDI beans from Quarkus extensions

I'm working on a Quarkus Extension. But I have some problems to inject CDI Beans.
In the runtime module I have this class:
#ApplicationScoped
public class CustomRestClientBuilder{
//#Produces - Removed
//#ApplicationScoped - Removed
public RestClientBuilder newBuilder(String url) throws MalformedURLException {
return RestClientBuilder.newBuilder().baseUrl(new URL(url));
}
}
In the deployment module, I have this class:
class RestClientExtensionProcessor {
private static final String FEATURE = "rest-client-extension";
#BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}
#BuildStep
public AdditionalBeanBuildItem producer() {
return new AdditionalBeanBuildItem(CustomRestClientBuilder.class);
}
}
And the problem appears in testing classes. I put the Test in Deployment module and it fails (however, in runtime module it works).
public class CustomRestClientBuilderTest {
#Inject
private CustomRestClientBuilder customRest;
#RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
#Test
public void testGreeting() {
IDummyRestClient restClient = customRest.newBuilder("url")
.build(IDummyRestClient.class);
}
}
The error is:
Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception:
javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException:
Unsatisfied dependency for type CustomRestClientBuilder and qualifiers [#Default]
I've checked this post before:
Exposing CDI beans from Quarkus extensions
UPDATED
This way is working (adding the class I need for testing). Does it makes sense?
#RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(CustomRestClientBuilder.class,
IDummyRestClient.class));

Awilix: Unable to resolve subclass with hard coded base class constructor parameters

I use the awilix library for achieving DI in my nodejs express project which used ES6 and nodejs 12.x.
Let's say I have a base class and a subclass as follows
class MyBaseClass {
#collectionName;
constructor(collectionName) {
this.#collectionName = collectionName;
}
getCollection() {
return this.#collection;
}
}
class MySubClass extends MyBaseClass {
constructor() {
super("users");
}
}
I use awilix.InjectionMode.CLASSIC. When I try to resolve and instance of MySubClass, I get a resolution error which basically says "Could not resolve 'collectionName'". MySubClass does not need constructor parameters to be passed in order to be instantiated. What am I doing wrong?

Typescript - asserting imported object to class static property

Having these two files:
ErrorCodesEnum.ts:
export const ErrorCodesEnum =
{
generic: {
NOT_FOUND: 'NOT_FOUND',
},
//...
}
Main.js:
import {ErrorCodesEnum} from "../enum/ErrorCodesEnum";
export class ErrorFactory {
public static CODES: ErrorCodesEnum; //error: see below.
}
I am getting following error in Main.js:
Public static property 'CODES' of exported class has or is using private name 'ErrorCodesEnum'.
Is there a way I can use some imported module in static class property?
Thanks.
You can't use ErrorCodesEnum as a type because it's not a type. You can reference its type using the typeof operator:
public static CODES: typeof ErrorCodesEnum;
Or if you're just trying to assign ErrorCodesEnum to CODES, just omit the type and set the value directly:
public static CODES = ErrorCodesEnum;

"Duplicate Zip Entry" (from Proguard) - renderscript-v8.jar

I am developing android application in Android Studio. There is no problem when I build the project an export signed APK without Proguard, but when I try to build the project with ProGuard(minifyEnabled true), there is an Proguard build failed with error like this:
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Can't write [user\myapplication\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar] (Can't read [user]sdkpath\SDK\build-tools\23.0.0\renderscript\lib\renderscript-v8.jar(;;;;;;**/*.class)] (Duplicate zip entry [renderscript-v8.jar:android/support/annotation/Keep.class]))
Here is my build.gradle codes
...
defaultConfig {
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
dependencies {
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile project(':libraries:gpuimage')
compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
}
Here is my proguard-rule.pro
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keep class *.R
-keep class *.R$* {*;}
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }
-keep public class * extends android.support.v4.view.ActionProvider {
public <init>(android.content.Context);
}
## Google AdMob specific rules ##
## https://developers.google.com/admob/android/quick-start ##
-keep public class com.google.ads.** {
public *;
}
## Google Analytics 3.0 specific rules ##
-keep class com.google.analytics.** { *; }
#-keep class it.sephiroth.** {*;}
-dontwarn it.sephiroth.**
Proguard Troubleshooting Say this
Warning: can't write resource ... Duplicate zip entry
Your input jars contain multiple resource files with the same name. ProGuard continues copying the resource files as usual, skipping any files with previously used names. Once more, the warning may be an indication of some problem though, so it's advisable to remove the duplicates. A convenient way to do so is by specifying filters on the input jars. There is no option to switch off these warnings.
android The standard Android build process automatically specifies the input jars for you. There may not be an easy way to filter them to remove these warnings. You could remove the duplicate resource files manually from the input and the libraries.
But i didn't figured out the which jar i added twice in my build..!
This might be related to a bug in renderscript-v8.jar in BuildTools 23.0.0, which included it's own copy of the annotation library and might cause error when used with some other support library.
I would suggest you try use BuildTools 23.0.3 and see if the problem goes away. 23.0.3 also included several other fixes for RenderScript.

SLF4J groovy annotation compilation error. 'log' was found in a static scope but doesn't refer to a local variable, static field or class

I've been staring at this block of code for a good hour trying to figure out why the log isn't being picked up at compile time. I'm using gradle to build and have dependencies listed as such:
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy:2.2.1'
compile 'org.slf4j:slf4j-api:1.7.6'
provided 'org.projectlombok:lombok:1.12.4'
runtime 'ch.qos.logback:logback-core:1.1.1'
runtime 'ch.qos.logback:logback-classic:1.1.1'
testCompile 'junit:junit:4.11'
}
My 'code block' is a class called FilesUtil annotated with #groovy.logging.util.SLF4J which contains a single static method that utilizes the log variable as the annotation javadoc suggests
import groovy.util.logging.Slf4j
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor
import java.nio.file.attribute.BasicFileAttributes
import static java.nio.file.FileVisitResult.CONTINUE;
#Slf4j
class FilesUtil {
def static deleteDirectory(Path path) {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
#Override
public FileVisitResult visitFile(Path file,
BasicFileAttributes attrs) throws IOException {
log.trace("deleting file: $file")
System.out.println("Deleting file: " + file)
Files.delete(file);
log.trace("deleted file: $file")
return CONTINUE;
}
#Override
public FileVisitResult postVisitDirectory(Path dir,
IOException exc) throws IOException {
if (exc == null) {
log.trace("deleting directory: $dir")
Files.delete(dir);
log.trace("deleted directory: $dir")
return CONTINUE;
} else {
throw exc;
}
}
})
}
}
Upon calling gradlew build (using the gradle wrapper) i get 4 similar errors like the following:
startup failed:
C:\Users\Macindows\IdeaProjects\corporate-git\subprojects\core\src\main\groovy\com\thenaglecode\corporategit\core\util\files\FilesUtil.groovy: 26:
Apparent variable 'log' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method 'log' but left out brackets in a place not allowed by the grammar.
# line 26, column 17.
log.trace("deleting file: $file")
^
Where's Wally? (the mistake I can't find... Waldo for you American folk)
Because you have an internal anonymous class it seems to be not seeing the generated log variable. If you change log.trace to FilesUtil.log.trace it seems to work.
Or if you use a Map as a proxy for SimpleFileVisitor it seems to work as well:
Files.walkFileTree(path, [ visitFile: { Path file, BasicFileAttributes attrs ->
log.trace("deleting file: $file")
System.out.println("Deleting file: " + file)
//Files.delete(file);
log.trace("deleted file: $file")
return CONTINUE;
},
postVisitDirectory: { Path dir, IOException exc ->
if (exc == null) {
log.trace("deleting directory: $dir")
//Files.delete(dir);
log.trace("deleted directory: $dir")
return CONTINUE;
} else {
throw exc;
}
} ] as SimpleFileVisitor )
Not sure of the underlying cause or if it's a bug at the moment...not got much time to think atm ;-)

Resources