我尝试将Github - CastCompanionLibrary-android is a library project集成到我的项目中,但是当构建时我遇到了这个错误:
D:\Android\MediaPlayer\app\src\main\java\com\google\android\libraries\cast\companionlibrary\cast\VideoCastManager.java:40:
error: cannot find symbol
import com.google.android.libraries.cast.companionlibrary.R; ^
我谷歌这么多,但尚未找到解决方案,我使用 Android工作室。 请帮我解决此解决方案
这是代码错误,位于文件VideoCastManager.java
import com.google.android.gms.cast.MediaInfo;
import com.google.android.gms.cast.MediaMetadata;
import com.google.android.gms.cast.MediaStatus;
import com.google.android.gms.cast.MediaTrack;
import com.google.android.gms.cast.RemoteMediaPlayer;
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult;
import com.google.android.gms.cast.TextTrackStyle;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.common.images.WebImage;
import com.google.android.libraries.cast.companionlibrary.R;
我已使用gradlew build --stacktrace
D:\Android\CastCompanionLibrary-android-master>gradlew build --stacktrace
:compileLint
:copyDebugLint UP-TO-DATE
:preBuild
:preDebugBuild
:checkDebugManifest
:preDebugTestBuild
:preReleaseBuild
:prepareComAndroidSupportAppcompatV72210Library
:prepareComAndroidSupportMediarouterV72210Library
:prepareComAndroidSupportSupportV42210Library
:prepareComGoogleAndroidGmsPlayServicesBase700Library
:prepareComGoogleAndroidGmsPlayServicesCast700Library
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:compileDebugJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:extractDebugAnnotations
:mergeDebugProguardFiles
:processDebugJavaRes UP-TO-DATE
:packageDebugJar
:compileDebugNdk
:packageDebugJniLibs UP-TO-DATE
:packageDebugLocalJar UP-TO-DATE
:packageDebugRenderscript UP-TO-DATE
:packageDebugResources
:bundleDebug
:assembleDebug
:copyReleaseLint UP-TO-DATE
:checkReleaseManifest
:prepareReleaseDependencies
:compileReleaseAidl
:compileReleaseRenderscript
:generateReleaseBuildConfig
:generateReleaseAssets UP-TO-DATE
:mergeReleaseAssets
:generateReleaseResValues
:generateReleaseResources
:mergeReleaseResources
:processReleaseManifest
:processReleaseResources
:generateReleaseSources
:compileReleaseJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:extractReleaseAnnotations
:mergeReleaseProguardFiles
:processReleaseJavaRes UP-TO-DATE
:packageReleaseJar
:compileReleaseNdk
:packageReleaseJniLibs UP-TO-DATE
:packageReleaseLocalJar UP-TO-DATE
:packageReleaseRenderscript UP-TO-DATE
:packageReleaseResources
:bundleRelease
:assembleRelease
:assemble
:lint
Ran lint on variant debug: 185 issues found
Ran lint on variant release: 185 issues found
Wrote HTML report to file:/D:/Android/CastCompanionLibrary-android-master/build/
outputs/lint-results.html
Wrote XML report to D:\Android\CastCompanionLibrary-android-master\build\outputs
\lint-results.xml
:check
:build
BUILD SUCCESSFUL
Total time: 3 mins 17.086 secs
D:\Android\CastCompanionLibrary-android-master>
答案 0 :(得分:1)
首先,确保您可以构建CastCompanionLibrary;将其克隆到本地文件系统并进入其根目录并尝试使用gradle构建:“./ gradlew build”。然后看看它是否成功构建。完成该步骤后,按照CastVideos项目中描述的相同步骤在您自己的项目中使用CCL。
答案 1 :(得分:0)
我已经解决了这个问题。
R.java is the dynamically generated class, created during build process to dynamically identify all assets (from strings to android widgets to layouts), for usage in java classes in Android app. Note this R.java is Android specific (though you may be able to duplicate it for other platforms, its very convenient) so it doesnt have much to do with Java language constructs. Take a look here, for more details.
因此,当我在项目中复制代码时,我需要更改清单中的包,而不是保留旧包。例:
变化
import com.google.android.libraries.cast.companionlibrary.R;
到
import com.example.android.uamp.R;