迁移到androidx之后NoClassDefFoundError Landroidx / lifecycle / LifecycleRegistry

时间:2019-03-06 11:22:48

标签: android noclassdeffounderror androidx

这是我需要克服的噩梦 迁移到androidx

之后发生
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/LifecycleRegistry;
            at androidx.lifecycle.ProcessLifecycleOwner.<init>(ProcessLifecycleOwner.java:62)
            at androidx.lifecycle.ProcessLifecycleOwner.<clinit>(ProcessLifecycleOwner.java:89)
            at androidx.lifecycle.ProcessLifecycleOwner.init(ProcessLifecycleOwner.java:102)
            at androidx.lifecycle.ProcessLifecycleOwnerInitializer.onCreate(ProcessLifecycleOwnerInitializer.java:37)
            at android.content.ContentProvider.attachInfo(ContentProvider.java:1920)
            at android.content.ContentProvider.attachInfo(ContentProvider.java:1894)
            at android.app.ActivityThread.installProvider(ActivityThread.java:7234)
            at android.app.ActivityThread.installContentProviders(ActivityThread.java:6721)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6618)
            at android.app.ActivityThread.-wrap2(Unknown Source:0)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2084)
            at android.os.Handler.dispatchMessage(Handler.java:109)
            at android.os.Looper.loop(Looper.java:166)
            at android.app.ActivityThread.main(ActivityThread.java:7555)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
         Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.lifecycle.LifecycleRegistry" on path: DexPathList[[zip file "/data/app/com.rowaad.cvaley-LXmiQJz1ijVJLVajJprVXA==/base.apk"],nativeLibraryDirectories=[/data/app/com.rowaad.cvaley-LXmiQJz1ijVJLVajJprVXA==/lib/arm64, /data/app/com.rowaad.cvaley-LXmiQJz1ijVJLVajJprVXA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /product/lib64]]

2 个答案:

答案 0 :(得分:0)

添加到 build.gradle:

dependencies {
    ...
   
   implementation "androidx.lifecycle:lifecycle-runtime:2.0.0"
   implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
   annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.0.0"
}

答案 1 :(得分:-1)

我更改了customerid;解决了这个问题

USE AdventureWorks2014
go

SELECT
    soh.CustomerID
   ,CONCAT(p.FirstName, ' ', p.LastName) AS [Full Name]
   ,cr.Name AS Country
   ,SUM(soh.TotalDue) AS Total_Sales
   ,YEAR(soh.OrderDate) AS Order_Year
FROM 
    Sales.SalesOrderHeader soh
JOIN 
    Sales.SalesTerritory st ON soh.TerritoryID = st.TerritoryID
JOIN 
    Person.CountryRegion cr ON st.CountryRegionCode = cr.CountryRegionCode
JOIN
    Sales.Customer c ON soh.CustomerID = c.CustomerID
JOIN 
    Person.Person p ON c.PersonID = p.BusinessEntityID
WHERE 
    YEAR(soh.OrderDate) = 2011
    AND soh.CustomerID = 30100
GROUP BY 
    soh.CustomerID
    ,p.FirstName
    ,p.LastName
    ,cr.Name
    ,soh.OrderDate