GetDataAsync().Result;
будет выполняться, когда задача, возвращаемая GetDataAsync()
, завершается, тем временем она блокирует поток пользовательского интерфейса return result.ToString()
]) помещается в очередь потока UI для выполнения GetDataAsync()
, будет завершена, когда будет запущено его очередное продолжение Тупик может быть нарушен предоставленными альтернативами, чтобы избежать Факт 1 или Факт 2.
var data = await GetDataAsync()
, который позволяет потоку пользовательского интерфейса продолжать работать var data = Task.Run(GetDataAsync).Result
, который выведет продолжение в контекст синхронизации потока threadpool. Это позволяет завершить задачу GetDataAsync()
. Это очень хорошо объясняется в статье Стивена Тууба , примерно наполовину вниз, где он использует пример DelayAsync()
.
У меня такая же проблема. Я думаю, что лучше всего на данный момент ждать, пока Google выпустит новое исправление Gradle.
В моем случае, если я удаляю -> применить плагин: «com.google.gms.google-services» & lt; - эта строка, ошибка предупреждения не отображается, но приложение не может инициировать firebase, поэтому приложение сбойное
перейти к вам build.gradle (уровень приложения)
и заменить слово «скомпилировать» "реализация"
будет работать на 100%
У меня есть одно и то же предупреждение, вызванное com.google.gms: google-services.
Решение заключается в обновлении classpath com.google.gms: google-services to classpath 'com.google.gms : google-services: 3.2.0 'в файле в build.gradle Project:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
В Android Studio verion 3.1 зависимые слова complie заменен на реализацию
зависимостями с предупреждением в студии android 3.1
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.1.0'
compile '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'
}
зависимостями OK в студии android 3.1
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.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'
}
Генерация градиров для Android Studio 3.1 для новый проект.
[/g3]
Посетите https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html
Подробнее https://docs.gradle.org/current/userguide/declaring_dependencies.html
Удачи вам
https://issuetracker.google.com/issues/72479188 указывает, что плагины иногда могут вводить «компилируемые» зависимости, и это то, что вызывает предупреждение. Вероятно, просто проще всего запустить эту проблему и подождать, пока они не исправят ее, чтобы указать, какие плагины вызывают проблему.
Откройте файл build.gradle, расположенный здесь:
Это старый способ написания библиотек зависимостей (для град версии 2 и ниже):
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/volley.jar')
compile 'com.android.support:support-v4:21.+'
}
Это новый (правый) способ импорта зависимостей для версии 3 градиента:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation files('libs/volley.jar')
implementation 'com.android.support:support-v4:21.+'
}
Я попытался изменить службы google gms на последнюю версию com.google.gms:google-services:3.2.1
в Android Studio 3.0.1, но предупреждение все еще сохраняется.
Как рекомендовал компилятор, я изменил все compile
зависимости на implementation
и testCompile
- testImplementation
, как это.
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-ads:12.0.1'
implementation 'com.google.firebase:firebase-crash:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-perf:12.0.1'
implementation 'com.google.firebase:firebase-appindexing:12.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
И, наконец, предупреждение удалено!
Использование последней версии служб google gms разрешило это для меня.
На уровне проекта build.gradle:
buildscript {
...
dependencies {
classpath 'com.google.gms:google-services:3.2.1'
...
}
}
В моем случае это является причиной библиотеки Realm после того, как я обновил ее до последней версии (5.1.0) Realm, проблема решена!
Вот сценарий рабочего градиента:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "io.realm:realm-gradle-plugin:5.1.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}
Я обновил com.google.gms: google-services от 3.2.0 до 3.2.1, и предупреждение перестало появляться.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.2.1'
}
}
Ответ google: https://issuetracker.google.com/issues/74048134
Там будет какая-то зависимость, использующая компиляцию, проверьте зависимости приложений и транзитивные зависимости тщательно.
перейдите в файл build.gradle на уровне проекта, вы увидите следующие строки:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4' //place your cursor over here
//and hit alt+enter and it will show you the appropriate version to select
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.2' //the same as previously
}
Я обновил com.google.gms:google-services
с 3.1.1
до 3.2.0
, и предупреждение перестало появляться.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.0'
}
}
Не нужно удалять строку. Как писал Джкревис, обновите com.google.gms: google-services до 3.2.0 и остановите предупреждения.
Обходной путь для решения этой проблемы был для меня тем, что я использовал более старую версию Gradle, которую можно найти здесь здесь :
Я использовал gradle-3.0-rc- 1-src, но другие могут работать тоже, хотя, вероятно, это не должно быть новее, чем версия 3.0.
Сначала извлеките zip-файл в любом месте.
Затем перейдите в File -> Settings -> Build, Execution, Deployment -> Gradle и измените настройку на Use local gradle distribution. После этого убедитесь, что поле Gradle Home - указывает на каталог .gradle в каталоге, который вы только что распаковали.
Перестройте проект, и все должно быть в порядке.