активность Android не распознает мой импорт

этот вопрос связан с этим. Моя активность не может реализовать lifecycleOwner Я полагаю, что этот вопрос может содержать ответ lifecycleOwner one. Я считаю, что этот ответ AppCompatActivity не реализует LifecycleOwner, но это не решило мою проблему

Я делаю проект Android в android. В каждом действии он просто не распознает мой импорт. как это:

private EditText edAccount;
edAccount = findViewById(R.id.edAccount);

он говорит: требуется: android.widget.EditText Found:android.view.View Но я делаю imports android.widget.EditText. Это произошло после того, как я импортировал новый библиотечный модуль. Но я не знаю, что происходит.

Кроме того, AppCompatActivity больше не реализует lifecycleOwner.

Спасибо за ваш ответ

build.gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.finaldesigntest"
        minSdkVersion 16
        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'
            debuggable true
        }
    }
    buildToolsVersion '27.0.3'
    productFlavors {
    }
}


repositories {
    flatDir {
        dirs 'libs'
    }
    mavenCentral()
}

repositories {
    flatDir { dirs project(':library').file('libs') }
//    maven { url 'https://jitpack.io' }
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    mavenCentral()
}

allprojects {
    repositories {
        //jcenter()
        //maven { url 'https://maven.google.com' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    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'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.contrarywind:Android-PickerView:4.0.1'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation project(':library')
    compile 'io.reactivex.rxjava2:rxjava:2.1.6'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'android.arch.lifecycle:runtime:1.1.1'
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'android.arch.lifecycle:reactivestreams:1.1.1'
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
}

это макет активности.xml

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.finaldesigntest.LoginActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal">
        <TextView
            android:layout_width="90dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:textSize="18sp"
            android:text="Account: "/>
        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/edAccount"
            android:layout_gravity="center_vertical"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal">
        <TextView
            android:layout_width="90dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:textSize="18sp"
            android:text="Password: "/>
        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/edPassword"
            android:layout_gravity="center_vertical"
            android:inputType="textPassword"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/remember_pass"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="18sp"
            android:text="Remember password"/>
    </LinearLayout>

    <Button
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:id="@+id/login"
        android:text="Login"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/view_login_result"/>

</LinearLayout>

person xiLianPeng    schedule 13.04.2018    source источник
comment
преобразовать вид в edittext, как в комментарии Хеманта   -  person Aswin P Ashok    schedule 13.04.2018
comment
Я думаю, что заглавные буквы имеют значение, поэтому EditText   -  person Zun    schedule 13.04.2018
comment
Во-первых, этого не происходит. Я хочу знать, как вернуться к прежнему образу жизни. тогда я могу решить проблему с жизненным циклом владельца. Спасибо   -  person xiLianPeng    schedule 13.04.2018
comment
Пожалуйста, дополните вопрос соответствующими зависимостями .xml и build.gradle.   -  person Gotiasits    schedule 13.04.2018
comment
@Gotiasits, я вставил свой build.gradle, пожалуйста, взгляните   -  person xiLianPeng    schedule 13.04.2018
comment
...и макет .xml, содержащий edAccount   -  person Gotiasits    schedule 13.04.2018
comment
@Gotiasits, это происходит с каждым занятием.   -  person xiLianPeng    schedule 13.04.2018
comment
У вас, вероятно, есть имя коалисона. У меня была аналогичная проблема с проектами с несколькими библиотеками. Переименуйте файлы .xml, чтобы они были уникальными во всех модулях. Также я не вижу edAccount в опубликованном .xml   -  person Gotiasits    schedule 13.04.2018
comment
извините, я получил неправильный xml, теперь я изменил его. Но все мои имена .xml уникальны. @Gotiasits   -  person xiLianPeng    schedule 13.04.2018


Ответы (2)


Убедитесь, что вы успешно построили свой проект. это происходит только тогда, когда сборка градиента не удалась.

person Prashant Jajal    schedule 13.04.2018
comment
разве это не должно быть комментарием? - person Aswin P Ashok; 13.04.2018
comment
Это был успешный проект, пока я не импортировал библиотеку модулей. тогда это произойдет - person xiLianPeng; 13.04.2018
comment
после добавления вашей библиотеки в ваш проект, это успех сборки.? @xiLianPeng - person Prashant Jajal; 13.04.2018
comment
проблема возникает после модуля импорта, поэтому не получается @PrashantJajal - person xiLianPeng; 13.04.2018
comment
может быть, ваш импортированный модуль имеет некоторую ошибку конфигурации. не могли бы вы добавить несколько вопросов Gradle Log для лучшего понимания. - person Prashant Jajal; 13.04.2018
comment
импортированный модуль в порядке. кстати, что такое журнал Gradle. - person xiLianPeng; 13.04.2018

Вам нужно бросить это так:

 private EditText edAccount;
 edAccount = (EditText) findViewById(R.id.edAccount);
person D. O.    schedule 13.04.2018
comment
Я знаю, что это работает, но я хочу знать, почему вдруг что-то пошло не так. Я надеюсь узнать причину, чтобы решить эту проблему. stackoverflow.com/q/49812582/9608562 - person xiLianPeng; 13.04.2018