This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
MainActivity_ is not abstract and does not override abstract method findViewById(int) in HasViews #2001
Copy link
Copy link
Closed
Description
I try to compile sample project with Android Studio 3.0-preview1 and Support Library 26.0.0-beta1 but get an compile time error "MainActivity_ is not abstract and does not override abstract method findViewById(int) in HasViews"
AndroidAnnotations version:
4.3.0
Android compile SDK version:
android-O
Project build config:
buildscript {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}Module build config:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-O'
buildToolsVersion "26.0.0-rc2"
defaultConfig {
applicationId "com.example.timurgilfanov.myapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-beta1'
annotationProcessor 'org.androidannotations:androidannotations:4.3.0'
compile 'org.androidannotations:androidannotations-api:4.3.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
Annotated code:
@EActivity(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {}Expected generated code:
public final class MainActivity_ extends MainActivity implements HasViews, OnViewChangedListener
{
...
@Override
public View findViewById(int id) {
...
}
...
}Actual generated code:
package com.example.timurgilfanov.myapplication;
import android.app.Activity;
import android.content.Context;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import org.androidannotations.api.builder.ActivityIntentBuilder;
import org.androidannotations.api.builder.PostActivityStarter;
import org.androidannotations.api.view.HasViews;
import org.androidannotations.api.view.OnViewChangedNotifier;
public final class MainActivity_ extends MainActivity implements HasViews
{
private final OnViewChangedNotifier onViewChangedNotifier_ = new OnViewChangedNotifier();
@Override
public void onCreate(Bundle savedInstanceState) {
OnViewChangedNotifier previousNotifier = OnViewChangedNotifier.replaceNotifier(onViewChangedNotifier_);
init_(savedInstanceState);
super.onCreate(savedInstanceState);
OnViewChangedNotifier.replaceNotifier(previousNotifier);
setContentView(R.layout.activity_main);
}
private void init_(Bundle savedInstanceState) {
}
@Override
public void setContentView(int layoutResID) {
super.setContentView(layoutResID);
onViewChangedNotifier_.notifyViewChanged(this);
}
@Override
public void setContentView(View view, LayoutParams params) {
super.setContentView(view, params);
onViewChangedNotifier_.notifyViewChanged(this);
}
@Override
public void setContentView(View view) {
super.setContentView(view);
onViewChangedNotifier_.notifyViewChanged(this);
}
public static MainActivity_.IntentBuilder_ intent(Context context) {
return new MainActivity_.IntentBuilder_(context);
}
public static MainActivity_.IntentBuilder_ intent(android.app.Fragment fragment) {
return new MainActivity_.IntentBuilder_(fragment);
}
public static MainActivity_.IntentBuilder_ intent(android.support.v4.app.Fragment supportFragment) {
return new MainActivity_.IntentBuilder_(supportFragment);
}
public static class IntentBuilder_
extends ActivityIntentBuilder<MainActivity_.IntentBuilder_>
{
private android.app.Fragment fragment_;
private android.support.v4.app.Fragment fragmentSupport_;
public IntentBuilder_(Context context) {
super(context, MainActivity_.class);
}
public IntentBuilder_(android.app.Fragment fragment) {
super(fragment.getActivity(), MainActivity_.class);
fragment_ = fragment;
}
public IntentBuilder_(android.support.v4.app.Fragment fragment) {
super(fragment.getActivity(), MainActivity_.class);
fragmentSupport_ = fragment;
}
@Override
public PostActivityStarter startForResult(int requestCode) {
if (fragmentSupport_!= null) {
fragmentSupport_.startActivityForResult(intent, requestCode);
} else {
if (fragment_!= null) {
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
fragment_.startActivityForResult(intent, requestCode, lastOptions);
} else {
fragment_.startActivityForResult(intent, requestCode);
}
} else {
if (context instanceof Activity) {
Activity activity = ((Activity) context);
ActivityCompat.startActivityForResult(activity, intent, requestCode, lastOptions);
} else {
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
context.startActivity(intent, lastOptions);
} else {
context.startActivity(intent);
}
}
}
}
return new PostActivityStarter(context);
}
}
}Stacktrace in case of AA crash:
MainActivity_ is not abstract and does not override abstract method findViewById(int) in HasViews
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
dodgex commentedon May 18, 2017
The Problem is that Google changed the signature of thier
findViewByIdin AndroidOfromView findViewById(int id)to something like<T extends View> T findViewById(int id)(not exactly sure how the new syntax looks, saw that yesterday in one of the I/O streams).And we have our
org.androidannotations.api.view.HasViewsinterface that has this method with the old syntax and until AndroidOthe implementation came from theActivityclass. but with this change on thier side they broke our interface...looks like for now we unfortunately do not support Android
Odue to this change.@WonderCsabo any idea for a good fix?
WonderCsabo commentedon May 18, 2017
I would suggest to generate the old,
findViewByIdmethod, but unfortunately that would not compile, because both methods have the same erasure. The only solution i see is introducing aHasViews2interface, and implement that ifcompileSdkVersion>= Android O .naixx commentedon May 22, 2017
@WonderCsabo Any update on the issue? Is it possible just to rename
findViewByIdmethod?dodgex commentedon May 26, 2017
A PR to adress this issue is up.
WonderCsabo commentedon Jun 7, 2017
@naixx no, we cannot just rename the method, because the generated code actually rely on implementing it implicitly by
Activity.phanminhthu commentedon Jan 18, 2018
Gradle add: maven { url 'https://jitpack.io' }.
buildscript {
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
AND:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
tir38 commentedon Jan 25, 2018
@phanminhthu can you explain what you are adding there?
MarcosiOSdev commentedon Jan 25, 2018
What is the solutions for "MainActivity_ is not abstract and does not override abstract method findViewById(int) in HasViews" ?????
MarcosiOSdev commentedon Jan 25, 2018
I solved ...
I putted on version 4.4.0 , and It has the method "findViewById(int) in HasViews"
edilsonvilarinho commentedon Apr 14, 2018
@marcosjava nice !!!
mjafartp commentedon Oct 24, 2018
com.android.tools.build:gradle version ?
edilsonvilarinho commentedon Nov 1, 2018
sim
peiandsky commentedon Nov 6, 2018
classpath 'com.android.tools.build:gradle:2.3.1'
Gradle 4.6