Open-source as well as ad-free. This project is not completed yet, upon completion it will be a music player with 3D spatial-audio, player-features, equalizer, Innovative widgets, system wide audio-switch & equalizer and a euphoric ui.
7
stars
0
forks
source link
Unsupported metadata version. Check that your Kotlin version is >= 1.0: java.lang.IllegalStateException: Unsupported metadata version. Check that your Kotlin version is >= 1.0 #1
After implementing Hilt for DI, the build fails and seems to have error.
You may use code below for reference, fix it and pull-request or implement hilt independently to improve architecture of the Equalized-Evo repo. The below file can be found in the HiltImp branch and working is on main branch.
@Provides
@Singleton
fun provideFetchMusic(@ApplicationContext context: Context): FetchMusic {
// Initialize and configure your FetchMusic instance here
return FetchMusic(context)
}
class ExoPlayer1 @Inject constructor(@ActivityContext val context: Context) {
private val exoPlayer = ExoPlayer.Builder(context).build()
var MediaList: List = emptyList()
fun getExoPlayer(): ExoPlayer {
return exoPlayer
}
fun playNext() {
if (exoPlayer.hasNextMediaItem()){
exoPlayer.seekToNextMediaItem()
}else{
Toast.makeText(context, "No Next Song", Toast.LENGTH_SHORT).show()
}
}
fun playPrev() {
if (exoPlayer.hasPreviousMediaItem()){
exoPlayer.seekToPreviousMediaItem()
}else{
Toast.makeText(context, "No Previous Song", Toast.LENGTH_SHORT).show()
}
}
After implementing Hilt for DI, the build fails and seems to have error.
You may use code below for reference, fix it and pull-request or implement hilt independently to improve architecture of the Equalized-Evo repo. The below file can be found in the HiltImp branch and working is on main branch.
Thanks to everyone willing to help :)
`package com.example.audioswitch_equalizedevo.ui.activities
import android.Manifest import android.content.pm.PackageManager import android.os.Build import android.os.Bundle import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels import androidx.annotation.RequiresApi import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.ui.Modifier import androidx.core.content.ContextCompat import androidx.lifecycle.ViewModelProvider import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import com.example.audioswitch_equalizedevo.data.Songs import com.example.audioswitch_equalizedevo.ui.screens.HomeScreen import com.example.audioswitch_equalizedevo.ui.screens.PlayerScreen import com.example.audioswitch_equalizedevo.ui.theme.AudioSwitch_EqualizedEvoTheme import com.example.audioswitch_equalizedevo.ui.viewModels.SongsViewModel import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint class MainActivity : ComponentActivity() { @RequiresApi(Build.VERSION_CODES.TIRAMISU) private val readAudioPermission = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) Manifest.permission.READ_MEDIA_AUDIO else Manifest.permission.READ_EXTERNAL_STORAGE private val requestPermissionLauncher: ActivityResultLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
if (isGranted) {
Toast.makeText(this, "Permission Granted", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this, "Permission is required to access Music Files, Enable it in device settings", Toast.LENGTH_SHORT).show()
}
}
}
package com.example.audioswitch_equalizedevo.data
import android.content.Context import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.components.ViewModelComponent import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Singleton
@Module @InstallIn(Singleton::class) object ExoplayerModule { @Provides @Singleton fun provideExoplayer(@ApplicationContext context: Context?): ExoPlayer1 { // Initialize and configure your ExoPlayer1 instance here return ExoPlayer1(context!!) // Replace null with actual ExoPlayer1 instance } }
@Module @InstallIn(Singleton::class) object FetchMusicModule {
}package com.example.audioswitch_equalizedevo.data
import android.content.Context import android.widget.Toast import androidx.media3.common.MediaItem import androidx.media3.exoplayer.ExoPlayer import dagger.hilt.android.qualifiers.ActivityContext import javax.inject.Inject
class ExoPlayer1 @Inject constructor(@ActivityContext val context: Context) { private val exoPlayer = ExoPlayer.Builder(context).build() var MediaList: List = emptyList()
}package com.example.audioswitch_equalizedevo.ui.viewModels
import android.net.Uri import androidx.lifecycle.ViewModel import androidx.media3.common.MediaItem import com.example.audioswitch_equalizedevo.data.ExoPlayer1 import com.example.audioswitch_equalizedevo.data.FetchMusic import com.example.audioswitch_equalizedevo.data.Songs import com.example.audioswitch_equalizedevo.ui.UIState import com.example.audioswitch_equalizedevo.ui.screenState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import javax.inject.Inject
@HiltViewModel class SongsViewModel @Inject constructor( val fetchMusic: FetchMusic, val exoPlayer: ExoPlayer1 ) : ViewModel() { private val _songs = MutableStateFlow<List>(emptyList())
val songs: StateFlow<List> = _songs
init {
fetchSongs()
}
}package com.example.audioswitch_equalizedevo.data
import android.content.ContentUris import android.content.Context import android.database.Cursor import android.net.Uri import android.provider.MediaStore import dagger.hilt.android.qualifiers.ActivityContext import javax.inject.Inject
class FetchMusic @Inject constructor(@ActivityContext val context: Context){
} plugins { alias(libs.plugins.androidApplication) alias(libs.plugins.jetbrainsKotlinAndroid) kotlin("kapt") id("com.google.dagger.hilt.android")
}
android { namespace = "com.example.audioswitch_equalizedevo" compileSdk = 34
}
dependencies { implementation("com.google.dagger:hilt-android:2.44") implementation(libs.material) implementation(libs.androidx.navigation.runtime.ktx) kapt("com.google.dagger:hilt-android-compiler:2.44") implementation(libs.androidx.core.ktx)
} kapt { correctErrorTypes = true }`