问题
I am trying to migrate to the new places SDK provided by google and they provided a compatibility script winch automates the process: https://developers.google.com/places/android-sdk/client-migration#compat-script
But I think that, I am not running it the way I should, I am doing it from my terminal in Android Studio and when it runs it simply says "sed can't read file [file name] no such directory exist" I am writing the command with my project's directory.
回答1:
I fixed it if anyone is interested that's how:
First, you need to download git bash in order to be able to run Linux commands on Windows, download it here: https://git-scm.com/downloads
Second copy the contents of: https://developers.google.com/places/android-sdk/client-migration#compat-script and save them somewhere on your local computer as: places_compat_compatify.sh
now open git bash and go to the directory where you saved the script (let's say you saved it on your desktop) then you must type cd Desktop, and cd D:\ if you saved it on then local disk D and so on, and then type dir to check if the file is there.
and then run this command ./places_compat_compatify.sh path-to-android-project 1.0.0
then open android studio and your implementations and import statements should be replaced with the new ones.
回答2:
The script didn't work for me either, it came up with errors such as:
sed: 1: "/Users/plo/dev/andro ...": invalid command code k
An alternative that worked for me was to use the Android Studios Find & Replace command (CMD+SHIFT+R), then replace the old import strings with the new ones. In addition, you should follow the other steps to:
- replace the
play-services-places
dependency with theplaces-compat
module - fix any emergent warnings or API methods on the Java/Kotlin code (minimal or none as the point of the compatibility library is to minimize code changes)
- any other step prescribed by the docs (Install the Compatibility Library) section
回答3:
If you use mac you will have an error "extra characters at the end of g command", for this you have to replace the line
find "$ {1}" -type f -regex "$ {2}" -not -regex ". * / \ (build \ | \ .idea \ | \ .git \ | \ .svn \) /.*" | xargs sed -i "" "s | $ {3} | $ {4} | g"
by
find "$ {1}" -type f -regex "$ {2}" -not -regex ". * / \ (build \ | \ .idea \ | \ .git \ | \ .svn \) /.*" | xargs sed -i "" "s | $ {3} | $ {4} | g"
with this the file works perfectly ./places_compat_compatify.sh
来源:https://stackoverflow.com/questions/54490165/how-do-i-run-googles-new-places-compat-compatify-sh-compatibility-script