Archinamon / android-gradle-aspectj

gradle plug-in adding supports of AspectJ into Android project
Apache License 2.0
365 stars 58 forks source link

APT compatibility? #5

Closed renaudcerrato closed 8 years ago

renaudcerrato commented 8 years ago

Hi!

It seems that the plugin is not APT friendly, Dagger now simply crash at startup:

Caused by: java.lang.IllegalStateException: Module adapter for class ***.app.AppModule could not be loaded. Please ensure that code generation was run for this module.

They're correctly generated in build/generated/source/apt/***:

image

How can I help?

Archinamon commented 8 years ago

Which versions did you use? Dagger and AspectJGradle too.

renaudcerrato commented 8 years ago

I'm using Dagger 1.2.2, AspectJ 1.8.7 (forced as explained here https://github.com/Archinamon/GradleAspectJ-Android/issues/4), android-apt plugin 1.8 and Android gradle-plugin 1.5.0 on Android Studio.

Not sure what you mean by AspectJGradle - didn't defined it.

Archinamon commented 8 years ago

Didn't found nothing wrong. My plugin works fine. Please, look at this example: https://github.com/Archinamon/AspectJExampleAndroid I've just updated it with Dagger.

renaudcerrato commented 8 years ago

Thanks - I'll check that and get back to you.

renaudcerrato commented 8 years ago

Just imported https://github.com/Archinamon/AspectJExampleAndroid:

Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources]
(...)

:app:compileDebugAspectj
2 errors

:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:compileDebugAndroidTestJavaWithJavac
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:compileDebugAndroidTestSources

BUILD SUCCESSFUL

Total time: 1.729 secs

Looking at ajc_details.log:

Wed Dec 16 11:45:39 EST 2015
/home/renaud/Workspace/AspectJExampleAndroid/com/archinamon/example/dagger/MyAppScopeModule$$ModuleAdapter.java [error] Internal compiler error: java.lang.IllegalArgumentException: Unknown location : SOURCE_OUTPUT at org.aspectj.org.eclipse.jdt.internal.compiler.apt.util.EclipseFileManager.getFileForOutput(EclipseFileManager.java:373)
(no source information available)
/home/renaud/Workspace/AspectJExampleAndroid/com/archinamon/example/dagger/MyAppScopeModule$$ModuleAdapter.java:16 [error] The type MyAppScopeModule$$ModuleAdapter is already defined
public final class MyAppScopeModule$$ModuleAdapter extends ModuleAdapter<MyAppScopeModule> {
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Right after that, the app launch but crashes, probably because of the silent ajc compiler failures:

java.lang.RuntimeException: Unable to instantiate application com.archinamon.example.MyApplication: java.lang.ClassNotFoundException: Didn't find class "com.archinamon.example.MyApplication"

Interestingly, the second build let us start the app (but none of aspects are running of course):

(...)
:app:compileDebugAspectj UP-TO-DATE
BUILD SUCCESSFUL

Doing a build->clean again make the crash re-appearing - the ajc compiler just fails again.

Archinamon commented 8 years ago

I found that the dagger itself works not well and not as expected. It creates strange folder. In my example project it's com/archinamon/example/dagger inside module root, not only in build/generated/apt/*/. I can't see this behaviour w/o aspectJ plugin. So I'll go deeper investigating this problem. My mind, that dagger some way breaks java compiler task. Do you have such problems with Dagger2?

Archinamon commented 8 years ago

Removing provided 'com.squareup.dagger:dagger-compiler:1.2.1' from project dependencies helps me avoiding strange re-creation generated files behaviour. Try it, please and feedback. I also updated example project, so you can look around.

renaudcerrato commented 8 years ago

Thanks! https://github.com/Archinamon/AspectJExampleAndroid is compiling and working just fine now. I too noticed that strange generated source directory created at the project root when your plugin is applied - but I haven't migrated to Dagger 2 yet to verify.

I'll try again on my own project and keep you updated.

renaudcerrato commented 8 years ago

Just tried again on my project: the ajc compiler still fails (and errors are still ignored...) and it seems to have issue with ButterKnife's generated classes:

Wed Dec 16 15:59:35 EST 2015
/home/renaud/Workspace/<hidden>/<hidden>/recyclerview/AnnoncePreviewHolderProvider$AnnonceViewHolder$$ViewBinder.java:8 [error] The type AnnoncePreviewHolderProvider$AnnonceViewHolder$$ViewBinder is already defined
public class AnnoncePreviewHolderProvider$AnnonceViewHolder$$ViewBinder<T extends <hidden>.recyclerview.AnnoncePreviewHolderProvider.AnnonceViewHolder> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/SearchResultsFragment$$ViewBinder.java:8 [error] The type SearchResultsFragment$$ViewBinder is already defined
public class SearchResultsFragment$$ViewBinder<T extends <hidden>.fragment.SearchResultsFragment> extends <hidden>.app.RecyclerViewFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/CategoryPickerFragment$CategoryViewHolder$$ViewBinder.java:8 [error] The type CategoryPickerFragment$CategoryViewHolder$$ViewBinder is already defined
public class CategoryPickerFragment$CategoryViewHolder$$ViewBinder<T extends <hidden>.fragment.CategoryPickerFragment.CategoryViewHolder> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/InboxFragment$InboxViewHolder$$ViewBinder.java:8 [error] The type InboxFragment$InboxViewHolder$$ViewBinder is already defined
public class InboxFragment$InboxViewHolder$$ViewBinder<T extends <hidden>.fragment.InboxFragment.InboxViewHolder> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/SplashScreenActivity$$ViewBinder.java:7 [error] The type SplashScreenActivity$$ViewBinder is already defined
public class SplashScreenActivity$$ViewBinder<T extends <hidden>.SplashScreenActivity> extends <hidden>.BaseLoginActivity$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/DebugActivity$$ViewBinder.java:8 [error] The type DebugActivity$$ViewBinder is already defined
public class DebugActivity$$ViewBinder<T extends <hidden>.DebugActivity> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/GalleryFragment$$ViewBinder.java:8 [error] The type GalleryFragment$$ViewBinder is already defined
public class GalleryFragment$$ViewBinder<T extends <hidden>.fragment.GalleryFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/AnnonceFragment$$ViewBinder.java:9 [error] The type AnnonceFragment$$ViewBinder is already defined
public class AnnonceFragment$$ViewBinder<T extends <hidden>.fragment.AnnonceFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/UserFragment$$ViewBinder.java:9 [error] The type UserFragment$$ViewBinder is already defined
public class UserFragment$$ViewBinder<T extends <hidden>.fragment.UserFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/FiltersMenuFragment$$ViewBinder.java:7 [error] The type FiltersMenuFragment$$ViewBinder is already defined
public class FiltersMenuFragment$$ViewBinder<T extends <hidden>.fragment.FiltersMenuFragment> extends <hidden>.fragment.AnimatedFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/ListingFragment$SyncOverlay$$ViewBinder.java:8 [error] The type ListingFragment$SyncOverlay$$ViewBinder is already defined
public class ListingFragment$SyncOverlay$$ViewBinder<T extends <hidden>.fragment.ListingFragment.SyncOverlay> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/MainActivity$$ViewBinder.java:9 [error] The type MainActivity$$ViewBinder is already defined
public class MainActivity$$ViewBinder<T extends <hidden>.MainActivity> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/DashboardFragment$$ViewBinder.java:8 [error] The type DashboardFragment$$ViewBinder is already defined
public class DashboardFragment$$ViewBinder<T extends <hidden>.fragment.DashboardFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/SellFragment$$ViewBinder.java:8 [error] The type SellFragment$$ViewBinder is already defined
public class SellFragment$$ViewBinder<T extends <hidden>.fragment.SellFragment> extends <hidden>.fragment.AnimatedFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/CountryPickerActivity$CountryAdapter$VH$$ViewBinder.java:8 [error] The type CountryPickerActivity$CountryAdapter$VH$$ViewBinder is already defined
public class CountryPickerActivity$CountryAdapter$VH$$ViewBinder<T extends <hidden>.CountryPickerActivity.CountryAdapter.VH> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/LocationPickerFragment$$ViewBinder.java:7 [error] The type LocationPickerFragment$$ViewBinder is already defined
public class LocationPickerFragment$$ViewBinder<T extends <hidden>.fragment.LocationPickerFragment> extends <hidden>.fragment.AnimatedFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/MainActivity$HeaderCoordinator$$ViewBinder.java:8 [error] The type MainActivity$HeaderCoordinator$$ViewBinder is already defined
public class MainActivity$HeaderCoordinator$$ViewBinder<T extends <hidden>.MainActivity.HeaderCoordinator> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/view/MessageComposerView$$ViewBinder.java:8 [error] The type MessageComposerView$$ViewBinder is already defined
public class MessageComposerView$$ViewBinder<T extends <hidden>.view.MessageComposerView> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/app/RecyclerViewFragment$$ViewBinder.java:8 [error] The type RecyclerViewFragment$$ViewBinder is already defined
public class RecyclerViewFragment$$ViewBinder<T extends <hidden>.app.RecyclerViewFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/UserInputFragment$$ViewBinder.java:7 [error] The type UserInputFragment$$ViewBinder is already defined
public class UserInputFragment$$ViewBinder<T extends <hidden>.fragment.UserInputFragment> extends <hidden>.fragment.AnimatedFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/DebugMessageFragment$$ViewBinder.java:8 [error] The type DebugMessageFragment$$ViewBinder is already defined
public class DebugMessageFragment$$ViewBinder<T extends <hidden>.fragment.DebugMessageFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/ConversationFragment$$ViewBinder.java:7 [error] The type ConversationFragment$$ViewBinder is already defined
public class ConversationFragment$$ViewBinder<T extends <hidden>.fragment.ConversationFragment> extends <hidden>.app.RecyclerViewFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/ConversationFragment$MessageViewHolder$$ViewBinder.java:8 [error] The type ConversationFragment$MessageViewHolder$$ViewBinder is already defined
public class ConversationFragment$MessageViewHolder$$ViewBinder<T extends <hidden>.fragment.ConversationFragment.MessageViewHolder> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/ListingFragment$$ViewBinder.java:7 [error] The type ListingFragment$$ViewBinder is already defined
public class ListingFragment$$ViewBinder<T extends <hidden>.fragment.ListingFragment> extends <hidden>.app.RecyclerViewFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/DashboardHeaderFragment$$ViewBinder.java:8 [error] The type DashboardHeaderFragment$$ViewBinder is already defined
public class DashboardHeaderFragment$$ViewBinder<T extends <hidden>.fragment.DashboardHeaderFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/recyclerview/AnnonceViewHolder$$ViewBinder.java:8 [error] The type AnnonceViewHolder$$ViewBinder is already defined
public class AnnonceViewHolder$$ViewBinder<T extends <hidden>.recyclerview.AnnonceViewHolder> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/FiltersMenuFragment$FilterViewHolder$$ViewBinder.java:9 [error] The type FiltersMenuFragment$FilterViewHolder$$ViewBinder is already defined
public class FiltersMenuFragment$FilterViewHolder$$ViewBinder<T extends <hidden>.fragment.FiltersMenuFragment.FilterViewHolder> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/BaseNumberUserInputFragment$Holder$$ViewBinder.java:8 [error] The type BaseNumberUserInputFragment$Holder$$ViewBinder is already defined
public class BaseNumberUserInputFragment$Holder$$ViewBinder<T extends <hidden>.fragment.BaseNumberUserInputFragment.Holder> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/MapOverlayCoordinator$$ViewBinder.java:8 [error] The type MapOverlayCoordinator$$ViewBinder is already defined
public class MapOverlayCoordinator$$ViewBinder<T extends <hidden>.fragment.MapOverlayCoordinator> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/ListingFragment$ListingAnnonceViewHolder$$ViewBinder.java:7 [error] The type ListingFragment$ListingAnnonceViewHolder$$ViewBinder is already defined
public class ListingFragment$ListingAnnonceViewHolder$$ViewBinder<T extends <hidden>.fragment.ListingFragment.ListingAnnonceViewHolder> extends <hidden>.recyclerview.AnnonceViewHolder$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/CountryPickerActivity$$ViewBinder.java:8 [error] The type CountryPickerActivity$$ViewBinder is already defined
public class CountryPickerActivity$$ViewBinder<T extends <hidden>.CountryPickerActivity> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/SellFragment$ImageViewHolder$$ViewBinder.java:8 [error] The type SellFragment$ImageViewHolder$$ViewBinder is already defined
public class SellFragment$ImageViewHolder$$ViewBinder<T extends <hidden>.fragment.SellFragment.ImageViewHolder> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/FacebookButtonFragment$$ViewBinder.java:8 [error] The type FacebookButtonFragment$$ViewBinder is already defined
public class FacebookButtonFragment$$ViewBinder<T extends <hidden>.fragment.FacebookButtonFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/CategoryPickerFragment$$ViewBinder.java:7 [error] The type CategoryPickerFragment$$ViewBinder is already defined
public class CategoryPickerFragment$$ViewBinder<T extends <hidden>.fragment.CategoryPickerFragment> extends <hidden>.fragment.UserInputFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/DebugChangesFragment$$ViewBinder.java:7 [error] The type DebugChangesFragment$$ViewBinder is already defined
public class DebugChangesFragment$$ViewBinder<T extends <hidden>.fragment.DebugChangesFragment> extends <hidden>.app.RecyclerViewFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/SingleChoiceUserInputFragment$$ViewBinder.java:7 [error] The type SingleChoiceUserInputFragment$$ViewBinder is already defined
public class SingleChoiceUserInputFragment$$ViewBinder<T extends <hidden>.fragment.SingleChoiceUserInputFragment> extends <hidden>.fragment.UserInputFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/LoginActivity$$ViewBinder.java:7 [error] The type LoginActivity$$ViewBinder is already defined
public class LoginActivity$$ViewBinder<T extends <hidden>.LoginActivity> extends <hidden>.BaseLoginActivity$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/HomeFragment$CategoryViewHolder$$ViewBinder.java:8 [error] The type HomeFragment$CategoryViewHolder$$ViewBinder is already defined
public class HomeFragment$CategoryViewHolder$$ViewBinder<T extends <hidden>.fragment.HomeFragment.CategoryViewHolder> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/AboutActivity$$ViewBinder.java:8 [error] The type AboutActivity$$ViewBinder is already defined
public class AboutActivity$$ViewBinder<T extends <hidden>.AboutActivity> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/AmazonS3Fragment$$ViewBinder.java:8 [error] The type AmazonS3Fragment$$ViewBinder is already defined
public class AmazonS3Fragment$$ViewBinder<T extends <hidden>.fragment.AmazonS3Fragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/HomeFragment$$ViewBinder.java:7 [error] The type HomeFragment$$ViewBinder is already defined
public class HomeFragment$$ViewBinder<T extends <hidden>.fragment.HomeFragment> extends <hidden>.app.RecyclerViewFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/BaseLoginActivity$$ViewBinder.java:8 [error] The type BaseLoginActivity$$ViewBinder is already defined
public class BaseLoginActivity$$ViewBinder<T extends <hidden>.BaseLoginActivity> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/HomeHeaderFragment$$ViewBinder.java:8 [error] The type HomeHeaderFragment$$ViewBinder is already defined
public class HomeHeaderFragment$$ViewBinder<T extends <hidden>.fragment.HomeHeaderFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/FiltersMenuFragment$PriceFilterViewHolder$$ViewBinder.java:7 [error] The type FiltersMenuFragment$PriceFilterViewHolder$$ViewBinder is already defined
public class FiltersMenuFragment$PriceFilterViewHolder$$ViewBinder<T extends <hidden>.fragment.FiltersMenuFragment.PriceFilterViewHolder> extends <hidden>.fragment.FiltersMenuFragment$FilterViewHolder$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/SearchResultsFragment$SearchAnnonceViewHolder$$ViewBinder.java:7 [error] The type SearchResultsFragment$SearchAnnonceViewHolder$$ViewBinder is already defined
public class SearchResultsFragment$SearchAnnonceViewHolder$$ViewBinder<T extends <hidden>.fragment.SearchResultsFragment.SearchAnnonceViewHolder> extends <hidden>.recyclerview.AnnonceViewHolder$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/UserAnnoncesFragment$UserAnnonceViewHolder$$ViewBinder.java:7 [error] The type UserAnnoncesFragment$UserAnnonceViewHolder$$ViewBinder is already defined
public class UserAnnoncesFragment$UserAnnonceViewHolder$$ViewBinder<T extends <hidden>.fragment.UserAnnoncesFragment.UserAnnonceViewHolder> extends <hidden>.recyclerview.AnnonceViewHolder$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/FavoritesFragment$FavoritesAnnonceViewHolder$$ViewBinder.java:7 [error] The type FavoritesFragment$FavoritesAnnonceViewHolder$$ViewBinder is already defined
public class FavoritesFragment$FavoritesAnnonceViewHolder$$ViewBinder<T extends <hidden>.fragment.FavoritesFragment.FavoritesAnnonceViewHolder> extends <hidden>.recyclerview.AnnonceViewHolder$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/FiltersMenuFragment$CategoryFilterViewHolder$$ViewBinder.java:7 [error] The type FiltersMenuFragment$CategoryFilterViewHolder$$ViewBinder is already defined
public class FiltersMenuFragment$CategoryFilterViewHolder$$ViewBinder<T extends <hidden>.fragment.FiltersMenuFragment.CategoryFilterViewHolder> extends <hidden>.fragment.FiltersMenuFragment$FilterViewHolder$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/UserAnnoncesFragment$$ViewBinder.java:7 [error] The type UserAnnoncesFragment$$ViewBinder is already defined
public class UserAnnoncesFragment$$ViewBinder<T extends <hidden>.fragment.UserAnnoncesFragment> extends <hidden>.app.RecyclerViewFragment$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/FiltersMenuFragment$LocationFilterViewHolder$$ViewBinder.java:7 [error] The type FiltersMenuFragment$LocationFilterViewHolder$$ViewBinder is already defined
public class FiltersMenuFragment$LocationFilterViewHolder$$ViewBinder<T extends <hidden>.fragment.FiltersMenuFragment.LocationFilterViewHolder> extends <hidden>.fragment.FiltersMenuFragment$FilterViewHolder$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/FiltersMenuFragment$SortFilterViewHolder$$ViewBinder.java:7 [error] The type FiltersMenuFragment$SortFilterViewHolder$$ViewBinder is already defined
public class FiltersMenuFragment$SortFilterViewHolder$$ViewBinder<T extends <hidden>.fragment.FiltersMenuFragment.SortFilterViewHolder> extends <hidden>.fragment.FiltersMenuFragment$FilterViewHolder$$ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/fragment/AnimatedFragment$$ViewBinder.java:8 [error] The type AnimatedFragment$$ViewBinder is already defined
public class AnimatedFragment$$ViewBinder<T extends <hidden>.fragment.AnimatedFragment> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/renaud/Workspace/<hidden>/<hidden>/view/RevealFrameLayout$$ViewBinder.java:8 [error] The type RevealFrameLayout$$ViewBinder is already defined
public class RevealFrameLayout$$ViewBinder<T extends <hidden>.view.RevealFrameLayout> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
renaudcerrato commented 8 years ago

Just added ButterKnife to your example, and I can confirm that ButterKnife is not yet compatible with your plugin:

Wed Dec 16 16:10:50 EST 2015
/home/renaud/Workspace/AspectJExampleAndroid/com/archinamon/example/MainActivity$$ViewBinder.java:8 [error] The type MainActivity$$ViewBinder is already defined
public class MainActivity$$ViewBinder<T extends com.archinamon.example.MainActivity> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^

Diff:

diff --git a/app/build.gradle b/app/build.gradle
index a35a7a4..bb2d6d0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -54,6 +54,8 @@ dependencies {
     apt 'com.squareup.dagger:dagger-compiler:1.2.1'
     compile 'com.squareup.dagger:dagger:1.2.1'

+    compile 'com.jakewharton:butterknife:7.0.1'
+
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile 'com.android.support:appcompat-v7:23.1.1'

diff --git a/app/src/main/java/com/archinamon/example/MainActivity.java b/app/src/main/java/com/archinamon/example/MainActivity.java
index d7a57c3..5d40063 100644
--- a/app/src/main/java/com/archinamon/example/MainActivity.java
+++ b/app/src/main/java/com/archinamon/example/MainActivity.java
@@ -1,25 +1,29 @@
 package com.archinamon.example;

-import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.TextView;
 import android.widget.Toast;
+
 import org.androidannotations.annotations.EActivity;
+
 import java.util.Locale;

+import butterknife.Bind;
+
 @EActivity
 public class MainActivity extends AppCompatActivity {

-    private TextView mHelloField;
+    @Bind(R.id.hello_world)
+    TextView mHelloField;

     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
-        mHelloField = (TextView) findViewById(R.id.hello_world);
     }

     @Override
Archinamon commented 8 years ago

Seems that error is still the same. Check it tomorrow. Thank's for your feedback!

renaudcerrato commented 8 years ago

Thanks for your time!

renaudcerrato commented 8 years ago

FYI, just migrated to Dagger 2 and I'm still getting those ***$$ViewBinder.java is already defined errors (which should be related to ButterKnife anyway).

The previous error (Unknown location : SOURCE_OUTPUT...) disappeared a while ago, well before migrating to Dagger 2 - probably when you updated your plugin to 1.1.0.

When the plugin is applied, at the root directory of my project, I'm still getting a weird directory which contains a copy of ButterKnife's generated classes, nothing more. Those classes should be in ./app/build/generated/source/apt instead:

renaud@stealth:~/Workspace/project$ rm -rf appname app/build && ./gradlew -q clean :app:assembleDebug && find . -name "MainActivity\$\$ViewBinder.java"
./app/build/generated/source/apt/debug/appname/MainActivity$$ViewBinder.java
./appname/MainActivity$$ViewBinder.java

That's probably the reason of the already defined error, but I was unable to look at the ajc arguments to verify.

Hope that help.

Archinamon commented 8 years ago

You have to try obsolete old artifact and try new one. To do this go to the inner gradle cache (for mac it's ~/.gradle/caches/modules-2/files-2.1/com.archinamon/AspectJ-gradle/, for win and linux look up .gradle folder within your user's home directory) and delete all folders with artifacts of different versions. files-2.1 folder may be with different number according to your gradle version. Also try to avoid using directive provided in gradle dependencies block to define dagger or dagger2 compiler api. Please, take a look again at my updated example project (same link I've posted above).

If your error will continue to occur, please send me your archived project I can reproduce your error with.

renaudcerrato commented 8 years ago

Just erased my whole gradle cache - and I'm still able to reproduce that error on your example by simply adding ButterKnife:

:app:compileDebugAspectj
1 error

:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:compileDebugAndroidTestJavaWithJavac
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:compileDebugAndroidTestSources

BUILD SUCCESSFUL

ajc_details.log give:

Thu Dec 17 14:52:46 EST 2015
/home/renaud/Workspace/AspectJExampleAndroid/com/archinamon/example/MainActivity$$ViewBinder.java:8 [error] The type MainActivity$$ViewBinder is already defined
public class MainActivity$$ViewBinder<T extends com.archinamon.example.MainActivity> implements ViewBinder<T> {
             ^^^^^^^^^^^^^^^^^^^^^^^

Here's the diff:

diff --git a/app/build.gradle b/app/build.gradle
index a35a7a4..bb2d6d0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -54,6 +54,8 @@ dependencies {
     apt 'com.squareup.dagger:dagger-compiler:1.2.1'
     compile 'com.squareup.dagger:dagger:1.2.1'

+    compile 'com.jakewharton:butterknife:7.0.1'
+
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile 'com.android.support:appcompat-v7:23.1.1'

diff --git a/app/src/main/java/com/archinamon/example/MainActivity.java b/app/src/main/java/com/archinamon/example/MainActivity.java
index d7a57c3..5d40063 100644
--- a/app/src/main/java/com/archinamon/example/MainActivity.java
+++ b/app/src/main/java/com/archinamon/example/MainActivity.java
@@ -1,25 +1,29 @@
 package com.archinamon.example;

-import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.TextView;
 import android.widget.Toast;
+
 import org.androidannotations.annotations.EActivity;
+
 import java.util.Locale;

+import butterknife.Bind;
+
 @EActivity
 public class MainActivity extends AppCompatActivity {

-    private TextView mHelloField;
+    @Bind(R.id.hello_world)
+    TextView mHelloField;

     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
-        mHelloField = (TextView) findViewById(R.id.hello_world);
     }

     @Override
Archinamon commented 8 years ago

Interesting. Didn't saw ButterKnife yet. Maybe only tomorrow :( But, please, test dagger and dagger2 to be sure, that they're works fine not only on my machine :) The situation when generated files appears in root of app was led by adding provided '...dagger2-compiler and provided '...dagger-compiler. As you can see in my example, adding provided 'javax.annotation... doesn't lead to this error estead of compiler api. In case of ButterKnife I see nothing similar in your build.gradle but need to take a deep look.

Thank's for your feedback anyway! Your help is highly appreciated! :)

renaudcerrato commented 8 years ago

As I confirmed previously, your sample is working fine since you upgraded it - so we're almost done =) Only ButterKnife is causing issues, and that's a REALLY common library :-/

I'd really love to use AspectJ on production... I'd love to contribute, but I'm not Gradle/AspectJ expert.

Thanks for your time - see you tomorrow then!

renaudcerrato commented 8 years ago

Hi there! Any update on that ButterKnife issue?

Archinamon commented 8 years ago

Hi! Still can't find problem in my code. But it's work if using apt-compiler for ButterKnife snapshot instead of simple pre-processor with 7.0.1 version. Will continue searching.

Archinamon commented 8 years ago

Hi. I did look up and investigate a problem with ButterKnife. I found two interesting behaviours: — not only my plugin makes strange generated files in the root of the project, others aj plugins too; — that's not breaks compilation and runtime for me; — but it still not so stable as I expected; I need to look deeper at android build tools 23+ to understand what can makes these issues. I'd suggest not to use butterknife with aspectj just for now, but I hope I'll fix it soon. I'm closing this thread and open understandable standalone issue about bk.

renaudcerrato commented 8 years ago

Ok. No AspectJ in production for me then.

Thanks for your time

Archinamon commented 8 years ago

@renaudcerrato Hello! Just added a workaround for ButterKnife with description of how to use it. https://github.com/Archinamon/GradleAspectJ-Android/issues/6#issuecomment-170271996