cinder92 / react-native-get-music-files

React Native package to get music files from local and sd for iOS and Android
MIT License
128 stars 64 forks source link

app can't start after installling it #57

Closed lylest closed 9 months ago

Drazail commented 4 years ago

@lylest please provide us with some context.

lylest commented 4 years ago

after successfully installing it when I tried to react-native run-android it stuck and fail with error logs but when I remove your package everything works just fine

here is my package. json file { "name": "Oplay", "version": "0.0.1", "private": true, "scripts": { "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "react": "16.8.6", "react-native": "0.60.5", "react-native-gesture-handler": "^1.4.1", "react-native-get-music-files": "^2.1.0", "react-native-permissions": "^1.2.0", "react-native-track-player": "^1.1.8", "react-native-vector-icons": "^6.6.0", "react-navigation": "^3.12.1" }, "devDependencies": { "@babel/core": "^7.5.5", "@babel/runtime": "^7.5.5", "@react-native-community/eslint-config": "^0.0.5", "babel-jest": "^24.9.0", "eslint": "^6.3.0", "jest": "^24.9.0", "metro-react-native-babel-preset": "^0.56.0", "react-test-renderer": "16.8.6" }, "jest": { "preset": "react-native" } }

and here is the error I am getting File C:\Users\Mela.android\repositories.cfg could not be loaded. Checking the license for package Android SDK Platform 25 in C:\Users\Mela\AppData\Local\Android\sdk\licenses License for package Android SDK Platform 25 accepted. <======-------> 50% CONFIGURING [15m 3s] <======-------> 50% CONFIGURING [15m 30s]] > :react-native-get-music-files <======-------> 50% CONFIGURING [15m 31s] <<======-------> 50% CONFIGURING [15m 38s] <======-------> 50% CONFIGURING [17m 24s] c

it stucks here forever

Drazail commented 4 years ago

@lylest

as you are using react-native 0.6+ please make sure you are linking the module correctly and then use jetifier to migrate.

I also noticed you are using react-native-track-player 1.1.8, you should use the v2 branch of that repository with react-native 0.6+

lylest commented 4 years ago

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 The message received from the daemon indicates that the daemon has disappeared. Build request sent: Build{id=8cf42187-6d4c-4b3e-ab46-522b140c8f7e, currentDir=D:\PROJECTS\react\Oplay\android} Attempting to read last messages from the daemon log... Daemon pid: 12116 log file: C:\Users\Mela.gradle\daemon\5.4.1\daemon-12116.out.log ----- Last 20 lines from daemon log file - daemon-12116.out.log ----- 05:22:38.784 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 492830720} 05:22:43.785 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 4175716352, Free: 771436544} 05:22:43.786 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 4175716352, Free: 771436544} 05:22:43.786 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 492830720} 05:22:46.802 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running 05:22:46.859 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry. 05:22:46.859 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry. 05:22:46.861 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry. 05:22:46.870 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry. 05:22:46.870 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry. 05:22:46.871 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry. 05:22:46.874 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry. 05:22:46.874 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry. 05:22:46.875 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry. 05:22:48.780 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 4175716352, Free: 771092480} 05:22:48.780 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 4175716352, Free: 771092480} 05:22:48.780 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 492830720} 05:22:53.781 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 4175716352, Free: 771260416} 05:22:53.781 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 4175716352, Free: 771260416} 05:22:53.781 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 492830720} ----- End of the daemon log -----

FAILURE: Build failed with an exception.

Drazail commented 4 years ago

@lylest

please share your code or reproduce the issue on a public repo.

lylest commented 4 years ago

it happens before i even run my app nor use it when i just install this package and run my app

lylest commented 4 years ago

but here is my code ` /**

import React, {Fragment} from 'react'; //import SearchBar from 'react-native-searchbar'; //import react-native-vector-icons from 'react-native-vector-icons';

import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, Image, TouchableOpacity, TextInput, KeyboardAvoidingView , Dimensions } from 'react-native';

import { Header, LearnMoreLinks, Colors,

} from 'react-native/Libraries/NewAppScreen'; const WIDTH = Dimensions.get('window').width; const HEIGHT = Dimensions.get('window').height; import TrackPlayer from 'react-native-track-player';

TrackPlayer.setupPlayer().then(async () => { await TrackPlayer.add({ id: 'trackId', url: require('../audio/sample.mp3'), title: 'Track Title', artist: 'Track Artist', artwork: require('../img/gal.jpg') }); });

export default class Home extends React.Component { constructor(props){ super(props); this.state = { playing:false, playicon:require('../img/play.png') } }

  playMusic()
  {
       //this.setState({playMusic:true})

      //this.setState({playMusic:false})
      if(this.state.playing == false){
           //do plap it
           TrackPlayer.play();
           this.setState({playing:true})
           this.setState({ playicon:require('../img/pause.png') })
      } else {
       this.pushMusic();

      }
  }

  pushMusic()
       {
        TrackPlayer.pause();
        this.setState({playing:false}) 
        this.setState({ playicon:require('../img/play.png') })
        //alert('alert')
       }

render() { return(

       <Fragment>
          <StatusBar backgroundColor="#DEC0C1" barStyle="dark-content" />
           <View style={styles.container}>

              <TouchableOpacity style={styles.bar}>
                 <View style={styles.barchild}>
                      <Image  style={styles.art} source={require('../img/art.jpg')} /></View>
                  <View style={styles.words}>
                      <Text style={styles.singer} numberOfLines={1}>Melo milly</Text>
                      <Text style={styles.song}>love er kill</Text>
                  </View>
                  <View style={styles.barchild2}>
                      <Text style={styles.time}>3:01</Text>
                  </View>

              </TouchableOpacity>

              <View style={styles.bar}>
                 <View style={styles.barchild}>
                      <Image  style={styles.art} source={require('../img/art.jpg')} /></View>
                  <View style={styles.words}>
                      <Text style={styles.singer} numberOfLines={1}>Melo milly</Text>
                      <Text style={styles.song}>love er kill</Text>
                  </View>
                  <View style={styles.barchild2}>
                      <Text style={styles.time}>3:01</Text>
                  </View>

              </View>

              <View style={styles.nowplaybar}>
              <View style={styles.barchild}>
                      <TouchableOpacity onPress={()=>this.props.navigation.navigate('NowPlaying')}>
                          <Image  style={styles.artsmall} source={require('../img/gal.jpg')} />
                          </TouchableOpacity>
                          </View>

                  <TouchableOpacity onPress={()=>this.props.navigation.navigate('NowPlaying')} style={styles.words}>
                      <Text style={styles.singersmall} numberOfLines={1}>Hansley</Text>
                      <Text style={styles.songsmall}>dear momy</Text>
                      </TouchableOpacity>

                  <TouchableOpacity 
                  onPress={() => this.playMusic()} style={styles.barchild2}>

                         <Image style={styles.pbtn} source={this.state.playicon} />
                     </TouchableOpacity>

              </View>
          </View>

         </Fragment>

       ) 
  }

}

const styles = StyleSheet.create({ container:{

}, pbtn:{ width:18, height:18, marginTop:10,

}, btn:{ marginTop:6, marginLeft:3, }, nowplaybar:{ width:'100%', height:50, backgroundColor:'#f2f2f2', position:'absolute', top:HEIGHT-65, left:0, right:0, shadowColor: '#f2f2f2', shadowOffset: { width: 1, height: 1}, shadowOpacity: 1, shadowRadius: 2, elevation: 2, borderRadius:4, flexDirection:'row', },

artsmall:{ width:30, height:30, borderRadius:4, margin:5,

}, words:{ width:'60%', flexDirection:'column', }, singersmall:{ fontWeight:'bold', paddingTop:5, paddingRight:3, marginLeft:-50, color:'#333745', fontSize:12, height:20,

}, songsmall:{ color:'#666', marginLeft:-50, marginTop:2, fontSize:9,

},

bar:{ width:'100%', height:80, flexDirection:'row', borderBottomColor:'#eee', borderBottomWidth:0.5,

}, barchild2:{ width:'30%',

}, barchild:{ width:'30%',

}, art:{ width:60, height:60, borderRadius:6, margin:10,

}, words:{ width:'60%', flexDirection:'column', }, singer:{ fontWeight:'bold', paddingTop:14, paddingRight:3, color:'#333745', fontSize:17, height:40,

}, song:{ color:'#666', paddingLeft:0, marginTop:2,

}, time:{ paddingTop:23, fontSize:10, paddingLeft:2, fontSize:10, color:'#666', },

});

`

Drazail commented 4 years ago

@lylest

maybe I was not clear in my previous comments, the problem doesn't originate from the JS part of your app but the native part.

if you are installing via npm please make sure you followed these steps:


  1. Open up android/app/src/main/java/[...]/MainApplication.java
    • Add com.cinder92.musicfiles.RNReatNativeGetMusicFilesPackage; to the imports at the top of the file
    • Add new RNReatNativeGetMusicFilesPackage() to the list returned by the getPackages() method
  2. Append the following lines to android/settings.gradle:
    include ':react-native-get-music-files'
    project(':react-native-get-music-files').projectDir = new File(rootProject.projectDir,  '../node_modules/react-native-get-music-files/android')
  3. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-get-music-files')

if you are installing via git Hub, please make sure you followed these steps as well as the steps above (if you wish to access RNAndroidAudioStore class that is, otherwise ignore these steps):


Open up android/app/src/main/java/[...]/MainApplication.java


now you need to convert your app to AndroidX, to do so follow these instructions.

lylest commented 4 years ago

My react native 0.60.5 doesn't permit manual linking of dependencies it throw a Warning And react native track player latest version is 1.1.8 no version two unless you got a link send it to me

Drazail commented 4 years ago

@lylest

If you follow the steps above, the package should work as expected, there are apps out there which are using RN 0.6+ and this package at the same time.


here's the link to the v2 branch of TrackPlayer: react-native-track-player v2

thoosi-raja commented 2 years ago

@Drazail * What went wrong: A problem occurred evaluating project ':react-native-get-music-files'.

Could not find method compile() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

I am getting this error when trying to run the app just after installing the package

Drazail commented 2 years ago

@thoosi-raja compile has been deprecated for a while now. use implementation instead.

I will take a look into this repo and will try to migrate it to newer versions of gradle, maven and react-native.

cinder92 commented 9 months ago

closing this in favor of https://github.com/cinder92/react-native-get-music-files/pull/108