簡體   English   中英

ClassNotFoundException:找不到類“androidx.support.constraint.ConstraintLayout”-api 28

[英]ClassNotFoundException: Didn't find class "androidx.support.constraint.ConstraintLayout" - api 28

我對 Gradle 文件進行了一些更改,當我嘗試運行該應用程序時出現此錯誤:java.lang.ClassNotFoundException:未找到類“androidx.support.constraint.ConstraintLayout”

------------XML------------

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:configChanges = "orientation|keyboardHidden"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="607dp"
        android:layout_height="313dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@mipmap/ic_launcher" />
</android.support.constraint.ConstraintLayout>

-----------Gradle 應用程序---------

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.eladk.flagged"
        minSdkVersion 27
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 

    "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta2'
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support:design:28.0.0'
        implementation 'com.android.support:support-annotations:28.0.0'
        implementation 'android.arch.lifecycle:extensions:1.1.1'
        testImplementation 'junit:junit:4.13-beta-3'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'com.android.support:recyclerview-v7:28.0.0'
        implementation 'com.google.android.gms:play-services-ads:18.1.1'
        implementation 'com.google.firebase:firebase-core:17.0.1'
        implementation 'com.google.android.gms:play-services-auth:17.0.0'
        implementation "com.google.ar.sceneform.ux:sceneform-ux:1.5.1"
    }
apply plugin: 'com.google.gms.google-services'

---------------Gradle 項目-----------------

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

- - - - - - - - 活動 - - - - - - - - - -

package com.example.eladk.flagged;

import android.content.Intent;
import android.os.Handler;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private int waitTime = 2500;

    private ImageView imageView;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imageView = (ImageView)findViewById(R.id.imageView);

        Animation Animation = AnimationUtils.loadAnimation(this, R.anim.transition);

        imageView.startAnimation(Animation);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(".SecondActivity");
                startActivity(intent);

您應該將您的項目遷移到 AndroidX,例如使用ConstraintLayout

 implementation "androidx.constraintlayout:constraintlayout:$constraintLayout_version"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM