Giter VIP home page Giter VIP logo

janishar / annotation-processing-example Goto Github PK

View Code? Open in Web Editor NEW
139.0 7.0 28.0 182 KB

It is the example project for the annotation processing tutorial.

Home Page: https://mindorks.com/blog/android-annotation-processing-tutorial-part-1-a-practical-approach

License: Apache License 2.0

Java 100.00%
annotation-processor annotation-processing android java butterknife tutorial mindorks example example-project example-code library modules

annotation-processing-example's Introduction

Android Annotation Processing Tutorial: Example Project

A complete library implementation

Annotation processing has become one of the most important language features in the modern Java programming. Java supports annotation processing from the release of Java 5 but its full potential has been realized in the recent years. Annotation processing in simple words is used to generate files during compilation.

About The Author

You can connect with me here:

The links to the tutorials:

  1. Part 1 : A practical approach
  2. Part 2: The project structure
  3. Part 3: Generate Java source code
  4. Part 4: Use the generated code

If this repository helps you in anyway, show your love ❤️ by putting a ⭐ on this project ✌️

How do I use this project?

This is a project aimed to help bootstrap new Android library for annotation processing. Feel free to fork this application.

License

   Copyright (C) 2023 JANISHAR ALI ANWAR

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Contributing to Android MVP Architecture

All pull requests are welcome, make sure to follow the coding best practices when you submit the pull request.

annotation-processing-example's People

Contributors

adityakamble49 avatar janishar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

annotation-processing-example's Issues

Can not generate binding source for inner class

When i change MainActivity for testing
public class MainActivity extends AppCompatActivity {

@BindView(R.id.tv_content)
TextView tvContent;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Binding.bind(this);
}

@OnClick(R.id.bt_1)
void bt1Click(View v) {
    tvContent.setText("Button 1 Clicked");
}

@OnClick(R.id.bt_2)
void bt2Click(View v) {
    tvContent.setText("Button 2 Clicked");
}
public class TestActivity  extends AppCompatActivity{
    @BindView(R.id.tv_content)
    TextView tvContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Binding.bind(this);
    }
}

}
Have no file "MainActivity$TestActivity$Binding.java" is created.
How can I inject for inner class?

When I ran the app, it crashed. Here is the error log.

com.mindorks.annotation.processing.example E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mindorks.annotation.processing.example, PID: 12858
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mindorks.annotation.processing.example/com.mindorks.annotation.processing.example.MainActivity}: java.lang.RuntimeException: Unable to find Class for com.mindorks.annotation.processing.example.MainActivity$Binding
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2807)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1540)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6359)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.RuntimeException: Unable to find Class for com.mindorks.annotation.processing.example.MainActivity$Binding
at com.mindorks.binder.Binding.instantiateBinder(Binding.java:42)
at com.mindorks.binder.Binding.bind(Binding.java:49)
at com.mindorks.annotation.processing.example.MainActivity.onCreate(MainActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6856)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2699)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2807) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1540) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:163) 
at android.app.ActivityThread.main(ActivityThread.java:6359) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mindorks.annotation.processing.example.MainActivity$Binding" on path: DexPathList[[zip file "/data/app/com.mindorks.annotation.processing.example-1/base.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.mindorks.annotation.processing.example-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.mindorks.annotation.processing.example-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.mindorks.binder.Binding.instantiateBinder(Binding.java:23)
at com.mindorks.binder.Binding.bind(Binding.java:49) 
at com.mindorks.annotation.processing.example.MainActivity.onCreate(MainActivity.java:23) 
at android.app.Activity.performCreate(Activity.java:6856) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2699) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2807) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1540) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:163) 
at android.app.ActivityThread.main(ActivityThread.java:6359) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770) 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.