I discovered YouTube Direct Lite (Android/Java) on GitHub (https://github.com/youtube/yt-direct-lite-android) as a good example of how to allow users to upload a video to your YouTube playlist. I've got it to work successfully in debug and release apk mode on Android 5.1.1 on Nexus 4 and Android 4.2.2. on Galaxy Tab 7. However, I get a "Connection to Play Services failed" message on installing to Android 7.0 on LG4. "Unfortunately, I-Witness (renamed app) Uploader has stopped" is the message before the app crashes, when I select my log-in account.
On initially importing the code from git, Android Studio 3.01 showed some outdated libraries, which I updated, and found a cure for a httprequest/httpclient error caused by one of said outdated libs. The biggest issues revolved around 'com.google.android.gms:play-services-auth' and 'com.google.android.gms:play-services-plus' which were at 7.8 in the original example.
Android Studio recommended update to the current 11.8 but when I did many 'red underlines of death' showed up in the code and so I was successful using 'com.google.android.gms:play-services-plus:9.0.0' and com.google.android.gms:play-services-auth:9.0.0.
Specifically, 11.8 causes a conflict with the below external libraries related to firebase, which I don't understand since firebase is not implemented in the project:
google.firebase:firebase-analytics-9.00
google.firebase:firebase-analytics-impl-9.00
google.firebase:firebase-common-9.00
google.firebase:firebase-core-9.00
google.firebase:firebase-iid-9.00
The problem seems to revolve around authenticating but where to debug for the specific Android version?
Here's my app level build.gradle if anyone might be familiar with YouTube direct Lite and can make a suggestion to resolve installation on Android 7:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.abengnews.iwitness"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//compile fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-plus:9.0.0'
implementation 'com.google.android.gms:play-services-auth:9.0.0'
//implementation 'com.google.android.gms:play-services-identity:9.0.0'
implementation 'com.android.support:appcompat-v7:27.0.2'
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.android.support:support-v13:27.0.2'
implementation 'com.google.apis:google-api-services-youtube:v3-rev120-1.19.0'
implementation 'com.google.http-client:google-http-client-android:+'
implementation 'com.google.api-client:google-api-client:1.23.0'
implementation 'com.google.api-client:google-api-client-android:1.23.0'
implementation 'com.google.api-client:google-api-client-gson:+'
implementation 'com.google.code.gson:gson:2.2.4'
implementation 'com.mcxiaoke.volley:library:1.0.18'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
}
configurations {
all {
exclude module: 'httpclient'
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
apply plugin: 'com.google.gms.google-services'
Thanks for any help.
P.S. It turns out the issue is related to <uses-permission android:name="android.permission.GET_ACCOUNTS" />
in the AndroidManifest.xml that was changed in Android 6.1>. I stumbled upon it while fiddling with the app's settings on the phone. "Contacts" was the only option listed under "Permissions" and when I enabled access to Contacts, the app functioned as expected.
Now I need to discover how to effect the permission programatically