KieronQuinn / AmbientMusicMod

Port of Now Playing from Pixels to other Android devices
GNU General Public License v3.0
1.93k stars 41 forks source link

Issue when cloning the project. #113

Closed githubashutoshsoni closed 2 years ago

githubashutoshsoni commented 2 years ago

I cloned the project but was faced with a security exception after installing the app on my phone.

FATAL EXCEPTION: DefaultDispatcher-worker-2
                                                                                                    Process: com.kieronquinn.app.ambientmusicmod, PID: 17412
                                                                                                    java.lang.SecurityException: Not allowed to bind to service Intent { act=com.kieronquinn.app.pixelambientmusic.RECOGNITION_SERVICE pkg=com.kieronquinn.app.pixelambientmusic }
                                                                                                        at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:2064)
                                                                                                        at android.app.ContextImpl.bindService(ContextImpl.java:1976)
                                                                                                        at com.kieronquinn.app.ambientmusicmod.repositories.AmbientServiceRepositoryImpl.getService(AmbientServiceRepository.kt:60)
                                                                                                        at com.kieronquinn.app.ambientmusicmod.repositories.DeviceConfigRepositoryImpl.sendValues(DeviceConfigRepository.kt:201)
                                                                                                        at com.kieronquinn.app.ambientmusicmod.repositories.DeviceConfigRepositoryImpl$sendInitial$1.invokeSuspend(DeviceConfigRepository.kt:191)
                                                                                                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

Can you please let me know what is going wrong and provide a fix? thanks!

KieronQuinn commented 2 years ago

Have you compiled both Now Playing and Ambient Music Mod, or just Ambient Music Mod?

githubashutoshsoni commented 2 years ago

I've compiled only ambient music mod. from this repository.

githubashutoshsoni commented 2 years ago

okay, i'm trying the readme of now playing will let you know if i face any issues then. thanks!

githubashutoshsoni commented 2 years ago

hey I've been getting this error. I have cloned both the projects. so, for NowPlaying I am running the command to generate the release build.

> Task :copyOverlay FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':copyOverlay'.
> from.listFiles() must not be null

Also despite having a local version of nowPlaying installed from the repository it keeps downloading when I open the ambientMusicMod. Should this be stopped because signature varies and I'm unable to install the nowplaying that is downloaded from the server. it should use the one that is currently installed? am I right?

KieronQuinn commented 2 years ago

Now a duplicate of #102. As for the downloading, it checks if the local version is the same version, so make sure you've not built with a different version code.

githubashutoshsoni commented 2 years ago

hey! So I was trying to build the NowPlaying. and this specific file was not present inside the overlay/src/main/smali this is required for the apktool.gradle.kts file.

val rawSmaliDir = File(overlaySrcMain, "smali")

the above smali file seems to be not existing at all. does this get added by you or by the system?

githubashutoshsoni commented 2 years ago

I got it. it was moved to base/smali now I'm able to get past that error. but somehow this is coming up.

W: Failed to generate resource table for split ''
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\res\values-v31\colors.xml:18: error: Error: No resource found that matches the given name (at 'gm3_ref_palette_dynamic_neutral99' with value '@android:color/system_neutral1_10').
W: 
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\bitcot\AppData\Local\Temp\brut_util_Jar_76230366080430464506049017271092255201.tmp, p, --forced-package-id, 127, --min-sdk-version, 28, --target
-sdk-version, 31, --version-code, 103, --version-name, 1.0.3, --no-version-vectors, -F, C:\Users\bitcot\AppData\Local\Temp\APKTOOL10787804982745532370.tmp, -e, C:\Users\bitcot\AppData\Local\Temp\APKTOOL13346353488948268968.tmp, -0, arsc, -I, C:\Users\bitcot\AppData\Local\apktool\framework\1.apk, -S, C:\Users\bitcot\StudioProjects\NowPlaying\base\res, -M, C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml]

> Task :compileBaseRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileBaseRelease'.
> Process 'command 'java'' finished with non-zero exit value 1
githubashutoshsoni commented 2 years ago

Can you please let me know which version of nowPlaying should I use for arm64 devices? it seems like some issue when doing recompliling of smali files.

KieronQuinn commented 2 years ago

The raw smali dir issue has now been fixed, pull the latest origin and it will be there.

As for your resource issue, you need to install a framework to APKtool. The instructions assume you have used apktool before, if you haven't, follow the steps on the Apktool documentation: https://ibotpeaches.github.io/Apktool/documentation/#frameworks

githubashutoshsoni commented 2 years ago

Thanks a lot @KieronQuinn . I read the documentation it seems like it needs an apk file for framework. I don’t have any pixel device at the moment to get the framework thing installed for my apktool. If you have it can you point out to the location or if not can you add to git? cheers

KieronQuinn commented 2 years ago

Any Android 12 or 13 framework will work.

githubashutoshsoni commented 2 years ago

so, I successfully got the 12 framework from my samsing m31 using device explorer. I installed the framework by giving it a samsung tag like this

PS C:\Users\bitcot\StudioProjects\NowPlaying> java -jar .\tools\apktool.jar if .\framework-res.apk -t samsung
I: Framework installed to: C:\Users\bitcot\AppData\Local\apktool\framework\1-samsung.apk

and in the gradle files I changed the decompile base to the following

task<Exec>("decompileBase") {
    doLast {
        assertApktool()
        assertBaseApk()
    }
    commandLine(
        "java",
        "-jar",
        apktoolJar.absolutePath,
        "d",
        "-o",
        baseDir.absolutePath,
        "-f",
        baseApk.absolutePath,
        "-t",
        "samsung"
    )
}

and decompile overlay to below

task<Exec>("decompileOverlay") {
    dependsOn("buildOverlay")
    val overlayModule = File(project.rootDir, "overlay")
    val overlayBuild = File(overlayModule, "build")
    val overlayOutputs = File(overlayBuild, "outputs")
    val overlayApkDir = File(overlayOutputs, "universal_apk")
    val overlayDebugApkDir = File(overlayApkDir, "debug")
    val overlayApk = File(overlayDebugApkDir, "overlay-debug-universal.apk")
    val decompiledDir = File(overlayBuild, "decompiled")
    doLast {
        assertApktool()
        if(!overlayApk.exists()){
            throw Exception("Overlay not built, run build first")
        }
    }
    commandLine(
        "java",
        "-jar",
        apktoolJar.absolutePath,
        "d",
        "-o",
        decompiledDir.absolutePath,
        "-f",
        overlayApk.absolutePath,
        "-t",
        "samsung"
    )
}

So both uses samsung framework that is present in andorid 12. after running the releaseApk --info I received the following error. it's the same one for resource error. i think.

 Task :compileBaseRelease
Caching disabled for task ':compileBaseRelease' because:
  Build cache is disabled
Task ':compileBaseRelease' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Starting process 'command 'java''. Working directory: C:\Users\bitcot\StudioProjects\NowPlaying Command: java -jar C:\User
s\bitcot\StudioProjects\NowPlaying\tools\apktool.jar b -f -o C:\Users\bitcot\StudioProjects\NowPlaying\build\out-release-unaligned.apk C:\Users\bitcot\StudioProjects\NowPlaying\base
Successfully started process 'command 'java''
I: Using Apktool 2.6.1
I: Smaling smali folder into classes.dex...
I: Smaling smali_classes10 folder into classes10.dex...
I: Smaling smali_classes11 folder into classes11.dex...
I: Smaling smali_classes12 folder into classes12.dex...
I: Smaling smali_classes13 folder into classes13.dex...
I: Smaling smali_classes14 folder into classes14.dex...
I: Smaling smali_classes15 folder into classes15.dex...
I: Smaling smali_classes16 folder into classes16.dex...
I: Smaling smali_classes17 folder into classes17.dex...
I: Smaling smali_classes18 folder into classes18.dex...
I: Smaling smali_classes19 folder into classes19.dex...
I: Smaling smali_classes2 folder into classes2.dex...
I: Smaling smali_classes20 folder into classes20.dex...
I: Smaling smali_classes21 folder into classes21.dex...
I: Smaling smali_classes3 folder into classes3.dex...
I: Smaling smali_classes4 folder into classes4.dex...
I: Smaling smali_classes5 folder into classes5.dex...
I: Smaling smali_classes6 folder into classes6.dex...
I: Smaling smali_classes7 folder into classes7.dex...
I: Smaling smali_classes8 folder into classes8.dex...
I: Smaling smali_classes9 folder into classes9.dex...
I: Building resources...
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:2: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_media_stream_on_gblue').
W: 
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:26: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/product_logo_now_playing_color_48').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:26: error: Error: No resource found that matches the given name (at 'label' with value '@string/history_activity_title').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:26: error: Error: No resource found that matches the given name (at 'theme' with value '@style/AmbientMusicSettingsTheme').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:38: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/product_logo_now_playing_color_48').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:38: error: Error: No resource found that matches the given name (at 'label' with value '@string/history_activity_title').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:48: error: Error: No resource found that matches the given name (at 'label' with value '@string/ambient_music_service_name').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:49: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_media_stream_on_gblue').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:49: error: Error: No resource found that matches the given name (at 'theme' with value '@style/SudThemeGlifV3.DayNight').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:50: error: Error: No resource found that matches the given name (at 'label' with value '@string/ambient_music_title').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:50: error: Error: No resource found that matches the given name (at 'theme' with value '@style/AmbientMusicSettingsTheme').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:51: error: Error: No resource found that matches the given name (at 'label' with value '@string/ambient_music_title').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:51: error: Error: No resource found that matches the given name (at 'theme' with value '@style/AmbientMusicSettingsTheme').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:62: error: Error: No resource found that matches the given name (at 'enabled' with value '@bool/enable_system_alarm_service_default').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:63: error: Error: No resource found that matches the given name (at 'enabled' with value '@bool/enable_system_job_service_default').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:64: error: Error: No resource found that matches the given name (at 'enabled' with value '@bool/enable_system_foreground_service_default').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:96: error: Error: No resource found that matches the given name (at 'enabled' with value '@bool/enable_system_alarm_service_default').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:109: error: Error: No resource found that matches the given name (at 'label' with value '@string/history_content_label').
W:
W: C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml:110: error: Error: No resource found that matches the given name (at 'label' with value '@string/history_content_label').
W:
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\bitcot\AppData\Local
\Temp\brut_util_Jar_73334908056603416825579721935115438344.tmp, p, --forced-package-id, 127, --min-sdk-version, 28, --targ
et-sdk-version, 31, --version-code, 103, --version-name, 1.0.3, --no-version-vectors, -F, C:\Users\bitcot\AppData\Local\Te
mp\APKTOOL3501653026738880225.tmp, -e, C:\Users\bitcot\AppData\Local\Temp\APKTOOL18445679730861041090.tmp, -0, arsc, -I, C
:\Users\bitcot\AppData\Local\apktool\framework\1-samsung.apk, -S, C:\Users\bitcot\StudioProjects\NowPlaying\base\res, -M, C:\Users\bitcot\StudioProjects\NowPlaying\base\AndroidManifest.xml]

> Task :compileBaseRelease FAILED
:compileBaseRelease (Thread[#689,Execution worker for ':',5,main]) completed. Took 25.796 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileBaseRelease'.
> Process 'command 'java'' finished with non-zero exit value 1

Do you know what I am doing wrong? link for my framework-apk file https://drive.google.com/file/d/1mGFFsKPuy6djKohJD4mHAO7tcq9uzr0B/view?usp=sharing

KieronQuinn commented 2 years ago

I tried installing the framework with apktool if framework-res.apk and it compiles fine. I suggest not using the tagging system, revert all your changes and just install it that way, then compile.

githubashutoshsoni commented 2 years ago

Thanks It's working fine now. the problem was with the base.apk file i was using the wrong one.