Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

插件项目存在自定义flavorDimensions时报has unknown dimension 'Shadow' #811

Closed
GitHubShy opened this issue Feb 16, 2022 · 7 comments
Labels
因陈旧关闭 未解决但因长时间无人跟进而关闭

Comments

@GitHubShy
Copy link

GitHubShy commented Feb 16, 2022

Hi guys!
我自己写的一个demo,是可以跑起来这一套逻辑的。但是我在我的插件项目里面就简单写个apply plugin: 'com.tencent.shadow.plugin'怎么一直报如下错误:

Caused by: java.lang.RuntimeException: Flavor 'normal' has unknown dimension 'Shadow'.
at com.android.build.gradle.internal.ProductFlavorCombo.createCombinations(ProductFlavorCombo.java:104)
at com.android.build.gradle.internal.VariantManager.populateVariantDataList(VariantManager.java:1038)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81)
at com.android.build.gradle.internal.VariantManager.createAndroidTasks(VariantManager.java:360)
at com.android.build.gradle.BasePlugin.lambda$createAndroidTasks$6(BasePlugin.java:800)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81)
at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:795)
at com.android.build.gradle.BasePlugin.lambda$null$4(BasePlugin.java:690)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81)
at com.android.build.gradle.BasePlugin.lambda$createTasks$5(BasePlugin.java:686)
at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91)
at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:80)


Gradle代码:
apply plugin: 'com.android.application'
apply plugin: 'com.tencent.shadow.plugin'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28

defaultConfig {
    project.archivesBaseName = "Monster"
    applicationId "com.center.Monster"
    minSdkVersion 25
    multiDexEnabled true

    ndk {
        abiFilters 'armeabi-v7a'
    }
    testInstrumentationRunner "com.senter.monitordaemon.testRunner.TestRunnerEmpty"
}

def flavorDistrict = "district"
def flavorDevice = "Device"
flavorDimensions flavorDevice, flavorDistrict

productFlavors {
    device1 {
        dimension flavorDevice
    }
    district1 {
        dimension flavorDistrict
    }

}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'


compileOnly 'com.tencent.shadow.core:runtime:1.0.0'

}

@shifujun
Copy link
Collaborator

应该是因为'flavorDimensions flavorDevice, flavorDistrict'把plugin自动添加的Shadow Dimension给覆盖掉了。

@GitHubShy
Copy link
Author

应该是因为'flavorDimensions flavorDevice, flavorDistrict'把plugin自动添加的Shadow Dimension给覆盖掉了。

那这应该咋整啊

@shifujun
Copy link
Collaborator

shifujun commented Feb 16, 2022

flavorDimensions(*flavorDimensionList, 'DimensionA', 'DimensionB')

这样写,把已存在的Dimension也添加回去就可以了。

@shifujun shifujun changed the title Ask for some favours 插件项目存在自定义flavorDimensions时报has unknown dimension 'Shadow' Feb 16, 2022
@GitHubShy
Copy link
Author

flavorDimensions(*flavorDimensionList, 'DimensionA', 'DimensionB')

这样写,把已存在的Dimension也添加回去就可以了。
非常感谢!
还有个问题是不是我们插件的Gradle和AGP是不是也得和你们的框架的兼容

@shifujun
Copy link
Collaborator

还有个问题是不是我们插件的Gradle和AGP是不是也得和你们的框架的兼容

不用完全一致。可以在这里看到Shadow有自动化测试这些版本的兼容性:

# 测试版本来源
# https://developer.android.com/studio/releases/gradle-plugin
setGradleVersion 7.2
testUnderAGPVersion 7.1.1
setGradleVersion 7.0.2
testUnderAGPVersion 7.0.0
testUnderAGPVersion 4.2.0
testUnderAGPVersion 4.1.0
setGradleVersion 6.1.1
testUnderAGPVersion 4.0.0
setGradleVersion 5.6.4
testUnderAGPVersion 3.6.0
setGradleVersion 5.4.1
testUnderAGPVersion 3.5.0
testUnderAGPVersion 3.4.0
testUnderAGPVersion 3.3.0
testUnderAGPVersion 3.2.0
testUnderAGPVersion 3.1.0
#更低的版本支持成本过高

@GitHubShy
Copy link
Author

GitHubShy commented Feb 17, 2022

还有个问题是不是我们插件的Gradle和AGP是不是也得和你们的框架的兼容

不用完全一致。可以在这里看到Shadow有自动化测试这些版本的兼容性:

# 测试版本来源
# https://developer.android.com/studio/releases/gradle-plugin
setGradleVersion 7.2
testUnderAGPVersion 7.1.1
setGradleVersion 7.0.2
testUnderAGPVersion 7.0.0
testUnderAGPVersion 4.2.0
testUnderAGPVersion 4.1.0
setGradleVersion 6.1.1
testUnderAGPVersion 4.0.0
setGradleVersion 5.6.4
testUnderAGPVersion 3.6.0
setGradleVersion 5.4.1
testUnderAGPVersion 3.5.0
testUnderAGPVersion 3.4.0
testUnderAGPVersion 3.3.0
testUnderAGPVersion 3.2.0
testUnderAGPVersion 3.1.0
#更低的版本支持成本过高

Hi, 现在我在宿主app里面加了android:sharedUserId="android.uid.system"变成系统app后,SDK会报错,因为Android禁止系统app使用webview

if (uid == android.os.Process.ROOT_UID || uid == android.os.Process.SYSTEM_UID) {
throw new UnsupportedOperationException(
"For security reasons, WebView is not allowed in privileged processes");
}

@shifujun caused by here

val latch = CountDownLatch(1)
Handler(Looper.getMainLooper()).post {
WebView(hostAppContext)
latch.countDown()
}
latch.await()

@shifujun
Copy link
Collaborator

和当前issue不相关的问题最好另外提issue。如果不需要使用WebView,可以删掉这段代码。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
因陈旧关闭 未解决但因长时间无人跟进而关闭
Projects
None yet
Development

No branches or pull requests

2 participants