IOError:[Errno 2]没有这样的文件或目录:u'/ .8. / RetroApp-debug.apk'

时间:2017-11-13 20:00:47

标签: android python python-3.x kivy buildozer

我是kivy库编程的初学者,但我做了非常简单的应用程序,就像在Kivy教程中一样。在桌面上它很酷。但是我想做.apk文件(没有使用Linux)。我已经尝试了很多步骤来做一个.apk文件,但最后我安装并打开了这个程序。它有一个错误。我已经尝试了很多规格和new_android,但没有任何效果。最后我将buildozer更新到最后一个版本。但现在,在buildozer android debug之后,他写了这个错误:

IOError:[Errno 2]没有这样的文件或目录:u'/ home / kivy / reyyy / .buildozer / android / platform / build / dists / RetroApp / build / outputs / apk / RetroApp-debug.apk'。

************* buildozer.spec ***************

import React from 'react';
import Request from 'superagent';
import _ from 'lodash';

export class Yum extends React.Component {
    constructor(){
        super();
        this.state = {
            searchQuery: 'onion',
            recipe: {
                ingredients: []
            }
        };

        this.search = this.search.bind(this);
        this.queryUpdate = this.queryUpdate.bind(this);
    }

    componentWillMount(){
        this.search(this.state.searchQuery);
    }

    render(){
        //const title = 'Onion Soup'; // Get this from somwhere else ?
        const {recipe, searchQuery} = this.state; // Get state properties
        const displayName = _.get(recipe, 'sourceDisplayName').map((sourceDisplayName) => {
            return (<h4>{displayName}</h4>)
        });

        const listItems = _.get(recipe, 'ingredients', []).map((ingredient, sourceDisplayName) => {
            return (<h5>{ingredient}</h5>);
        });

        return(
            <div>
                <input onChange={this.queryUpdate} type="text" value={searchQuery} />

                <h4>{displayName}</h4>
                <ul>
                    <li>{listItems}</li>
                </ul>
            </div>
        )
    }

    queryUpdate(event) {
        const searchQuery = event.target.value; // Get new value from DOM event
        this.setState({searchQuery}); // Save to state
        this.search(searchQuery); // Search
    }

    search(searchQuery) {
        const url = `http://api.yummly.com/v1/api/recipes?_app_id=5129dd16&_app_key=9772f1db10ba433223ad4e765dc2b537&q=${searchQuery}&maxResult=1`
        Request.get(url).then((response) => {
            this.setState({
                recipe: response.body.matches[0]
            });
        });
    }
}

export default Yum;

****** python3:main.py *******

[app]

title = Retro App

package.name = retroapp


package.domain = org.test

source.dir = .

source.include_exts = py,png,jpg,kv,atlas

version = 1.0

requirements = kivy

orientation = landscape

osx.python_version = 3

osx.kivy_version = 1.9.1

fullscreen = 1

android.arch = armeabi-v7a

[buildozer]

log_level = 2

warn_on_root = 1

******** KV pong.kv *********

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty,ObjectProperty,ReferenceListProperty,StringProperty
from kivy.vector import Vector
from kivy.clock import Clock
from kivy.uix.button import Button
from random import randint,choice


class RetryButton(Button):
    pass

class PongBall(Widget):
    velocity_y = NumericProperty(0)
    velocity_x = NumericProperty(0)

    velocity = ReferenceListProperty(velocity_x,velocity_y)
    def move(self):
        self.pos = Vector(*self.velocity)+self.pos

class PongPaddle(Widget):
    score = NumericProperty(0)

    def bounce_ball(self,ball):
        if self.collide_widget(ball):
            vx,vy = ball.velocity
            offset = (ball.center_y - self.center_y) / (self.height /10.0)
            bounced = Vector(-1 * vx, vy)
            vel = bounced * 1.1
            ball.velocity = vel.x, vel.y + offset

class PongGame(Widget):
    ball = ObjectProperty(None)
    player1 = ObjectProperty(None)
    player2 = ObjectProperty(None)
    win = NumericProperty(0)
    middle_rectangle_opacity = NumericProperty(1)
    winner = StringProperty('')
    def __init__(self,**q):
    super().__init__(**q)
        self.btn = RetryButton(width = self.width)
        self.btn.count = 0
        self.max_score = 10

    def serve_ball(self,vel = (10,0)):
        self.ball.center =  self.center
        self.ball.velocity = Vector(*vel).rotate(choice([randint(0,30),randint(330,360)]))

    def update(self,dt):
        if self.win == 0:

            self.ball.move()
            self.player1.bounce_ball(self.ball)
            self.player2.bounce_ball(self.ball)
            if self.player1.score >= self.max_score or self.player2.score >=self.max_score:
                if self.player1.score >= self.max_score:
                    self.winner = '1'
                else:
                    self.winner = '2'
                self.win = 1
                self.middle_rectangle_opacity = 0

            if (self.ball.y < self.y) or (self.ball.top > self.height):
                self.ball.velocity_y *= -1

            if self.ball.x<self.x:
                self.player2.score += 1
                self.serve_ball((10,0))
            if self.ball.x > self.width - self.ball.width:
                self.player1.score += 1
                self.serve_ball((-10,0))
        else:
            if self.btn.count == 0:
                self.btn.bind(on_press=self.retry)
                self.add_widget(self.btn)
                self.btn.count += 1

    def on_touch_move(self, touch):
        if touch.x < self.width/3.0:
            self.player1.center_y = touch.y
        if touch.x > self.width - self.width/3.0:
            self.player2.center_y = touch.y

    def retry(self,*q):

        self.player1.score = 0
        self.player2.score = 0
        self.win = 0
        self.middle_rectangle_opacity = 1
        self.serve_ball()
        self.remove_widget(self.btn)
        self.btn.count = 0

class PongApp(App):
    def build(self):
        game = PongGame()
        game.serve_ball()
        Clock.schedule_interval(game.update, 1/30.0)
        return game

if __name__ == '__main__':
    PongApp().run()`

请帮帮我! 瓦迪姆。

1 个答案:

答案 0 :(得分:1)

请更改您的Python脚本,如下所示:

main.py

class PongGame(Widget):
...
    def __init__(self, **kwargs):
        super(PongGame, self).__init__(**kwargs)
...

    def retry(self):

由于您使用的是Python 3.x,因此需要执行以下操作:

  1. 使用python3支持安装Buildozer

    git clone https://github.com/kivy/buildozer

    cd buildozer

    python setup.py build

    sudo pip install -e。

  2. 在某处下载并解压缩Crystax NDK(〜/ opt /是一个选项):https://www.crystax.net/en/download

  3. 在buildozer.spec中指定以下内容:
  4. buildozer.spec

    requirements = python3crystax,kivy

    android.ndk = 10.3.2

    android.ndk_path = /opt/crystax-ndk-10.3.2